ERROR RECEIVED: NullReferenceException was unhandled
Object reference not set to an instance of an object.
And it points on the particular line: dsNewRow = ds.Tables("Employees").NewRow()
Imports System.Data.OleDb
Public Class Register
Public cn As New OleDbConnection
Public rd As OleDbDataReader
Public da As New OleDbDataAdapter
Public ds As New DataSet
Public str As String
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cb As New OleDb.OleDbCommandBuilder(da)
Dim dsNewRow As DataRow
dsNewRow = ds.Tables("Employees").NewRow
dsNewRow.Item("Given Name") = txtGivenName.Text
dsNewRow.Item("Last Name") = txtLastName.Text
dsNewRow.Item("Gender") = cmbGender.Text
dsNewRow.Item("Month") = cmbMonth.Text
dsNewRow.Item("Day") = cmbDay.Text
dsNewRow.Item("Year") = cmbYear.Text
dsNewRow.Item("Address") = txtAddress.Text
dsNewRow.Item("Email Address") = txtEmailAddress.Text
dsNewRow.Item("Username") = txtUsername.Text
dsNewRow.Item("Password") = txtPassword.Text
dsNewRow.Item("Secret Question 1") = cmbSecretQ1.Text
dsNewRow.Item("Secret Question 2") = cmbSecretQ2.Text
dsNewRow.Item("Secret Answer 1") = txtSecretA1.Text
dsNewRow.Item("Secret Answer 2") = txtSecretA2.Text
ds.Tables("Employees").Rows.Add(dsNewRow)
da.Update(ds, "Employees")
MsgBox("New employee added to the database!")
SuccessRegister.ShowDialog()
Profile.Show()
Me.Hide()
End Sub
End Class