I am working with my project and having a hard time on how to update multiple data using datagridview. I will display the data from my database to my datagridview in my form 1 after searching. From there, I will update and insert data in the database from my datagridview. I can insert data to my datagridview but when I will Update it by clicking my Update Button, an error message will display.
Here is my code:
private void button1_Click(object sender, EventArgs e)
MySqlConnection = new SqlConnection("Data Source=BENJ\\SQLEXPRESS;Initial Catalog= ComputerizedEnrollmentSystem; User ID=sa; Password=aspire4736z");
m_da = new SqlDataAdapter("SELECT StudentID as 'Student Number', StudentFirstName as 'First Name', StudentLastName as 'Last Name', GradeLevel as 'Level', SectionName as 'Section Name', SectionCode as 'Section Code',FinalGrade as 'Final Grade' From tblClass Where GradeLevel='" + comboBox1.SelectedItem + "' AND SectionName='" + comboBox2.SelectedItem + "' AND SectionCode='" + comboBox3.SelectedItem + "' ", MySqlConnection);
ds = new System.Data.DataSet();
dg_grade.DataSource = ds.Tables;
private void button2_Click(object sender, EventArgs e)
cmd = new SqlCommandBuilder(m_da);
MessageBox.Show("Grade Inserted Successfully", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Here is the error message:
"Dynamic SQL Generation for the UpdateCommand is not supported against a SelectCommand that does not return any key column information "
Please somebody help me :) I am new here.