mySQL :syntax using in C#
- by Meko
Hi. I am using in C# MYsql .I have query that works if I run on MySql Workbench ,but in C# it does not return any value also does not give ant error too.There is only one different using on Mysql I use before table name  databaseName.tableName , but in C# I think it doesn`t necessary.
This is part of query which does not return anything.
"(select Lesson_Name from schedule  where Group_NO = (select Group_NO from sinif inner join student ON sinif.Group_ID=student.Group_ID where Student_Name=(?Student))"+
           " And Day_Name =(select Day_Name from day inner join date ON day.Day_ID=date.DayName where Date=(?Date))" +
           "And Lesson_Time= (select Lesson_Time from clock where Lesson_Time <= (?Time)order by Lesson_Time DESC limit 0, 1) " +
           " And Week_NO = (select Week_NO from week inner join date ON week.Week_ID=date.Week_ID where Date=(?Date)))
And Here all codes which executes when user click button.
 private void check_B_Click(object sender, EventArgs e)
    {
        connection.Open();
       for (int i = 0; i < existingStudents.Count; i++)
        {
            MySqlCommand cmd1 = new MySqlCommand("select Student_Name,Student_Surname,Student_MacAddress from student  ", connection);
            MySqlCommand cmd2 = new MySqlCommand("insert into check_list (Student,Mac_Address,Date,Time,Lesson_Name)"+
           "values((?Student),(?MacAddress),(?Date),(?Time),"+
           "(select Lesson_Name from schedule  where Group_NO = (select Group_NO from sinif inner join student ON sinif.Group_ID=student.Group_ID where Student_Name=(?Student))"+
           " And Day_Name =(select Day_Name from day inner join date ON day.Day_ID=date.DayName where Date=(?Date))" +
           "And Lesson_Time= (select Lesson_Time from clock where Lesson_Time <= (?Time)order by Lesson_Time DESC limit 0, 1) " +
           " And Week_NO = (select Week_NO from week inner join date ON week.Week_ID=date.Week_ID where Date=(?Date))))", connection);
            MySqlParameter param1 = new MySqlParameter();
            param1.ParameterName = "?Student";
            reader = cmd1.ExecuteReader();
            if (reader.HasRows)
                while (reader.Read())
                {
                    if (reader["Student_MacAddress"].ToString() == existingStudentsMac[i].ToString())
                        param1.Value = reader["Student_Name" ]+" "+reader["Student_Surname"];
                }
            reader.Close();
            MySqlParameter param2 = new MySqlParameter();
            param2.ParameterName = "?MacAddress";
            param2.Value = existingStudentsMac[i];
            MySqlParameter param3 = new MySqlParameter();
            param3.ParameterName = "?Date";
            param3.Value = DateTime.Today.Date;
            MySqlParameter param4 = new MySqlParameter();
            param4.ParameterName = "?Time";
            param4.Value = DateTime.Now.ToString("HH:mm");
            cmd2.Parameters.Add(param1);
            cmd2.Parameters.Add(param2);
            cmd2.Parameters.Add(param3); 
            cmd2.Parameters.Add(param4);
           cmd2.ExecuteNonQuery();
        }
        connection.Close();
        MessageBox.Show("Sucsess :)");
    }