我正在尝试使用vb向访问数据库添加新行但是我收到此错误 - 附加信息:对象引用未设置为对象的实例。 任何人都可以看到我可以解决这个问题吗?
Public Class frmLecturer
Dim objConnection As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0" &
"Data Source = StudentDatabase1.accdb")
Dim objStudentDA As New OleDb.OleDbDataAdapter("Select * FROM StudentDatabase", objConnection)
Dim objStudentCB As New OleDb.OleDbCommandBuilder(objStudentDA)
Dim objDs As New DataSet()
Dim rowIndex As Integer
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
'ERROR HERE
Dim objRow As DataRow = objDs.Tables("StudentDatabase").NewRow()
Dim strStudentID As String
CstrStudentID = txtStudentNum.Text
'Editing each field value based on textboxes
objRow("ID") = strStudentID
objRow.Item("FName") = txtName.Text
objRow.Item("SName") = txtSurname.Text
objRow.Item("Attendance") = txtAttendance.Text
objRow.Item("CA1") = txtCA1.Text
objRow.Item("CA2") = txtCA2.Text
CobjRow.Item("FinalExam") = txtFinalExamResult.Text
objRow.Item("OverallGrade") = txtOverallResult.Text
objDs.Tables("StudentDatabase").Rows.Add(objRow)
objStudentDA.Update(objDs, "StudentDatabase")
End Sub
End Class