Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\xxxx\xxxx.mdb"
cmd.Connection = con
Dim Count As Integer = 0
con.Open()
For Count = 0 To DataGridView1.Rows.Count - 1
Dim dr As New DataGridViewRow
dr = DataGridView1.Rows(Count)
cmd.CommandText = "update StudentGrade set grade = '" & dr.Cells(5).Value & "' where studentid = " & dr.Cells(0).Value & "AND subjectcode = " & dr.Cells(2).Value
Next
MessageBox.Show("บันทึกข้อมูลแล้ว")
con.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub