当我使用包含主题代码的用户凭据登录以输入在DataGrid中为特定主题注册的学生的标记并保存到SQL Server数据库时,相同的标记为学生在登录时显示在DataGrid中的条目是使用不同的主题代码。
如果有人可以修改以下代码来解决问题,我将不胜感激。
Private Sub dgMarksEntry_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgMarksEntry.Enter
Try
For i = 0 To dgMarksEntry.Rows.Count - 1
cmd = New SqlCommand("select * from StudentDetails.MarksEntry where RegDNumber=" & Val(dgMarksEntry.Item(0, i).Value) & " ", cn)
dr = cmd.ExecuteReader
If dr.Read Then
dgMarksEntry.Item(2, i).Value = dr(1)
dgMarksEntry.Item(3, i).Value = dr(2)
dgMarksEntry.Item(4, i).Value = dr(3)
dgMarksEntry.Item(5, i).Value = dr(4)
dgMarksEntry.Item(6, i).Value = dr(5)
dgMarksEntry.Item(7, i).Value = dr(6)
End If
dr.Close()
Next
Catch ex As Exception
MessageBox.Show("MarksError:" & ex.Message)
End Try