Hi guys,
i have encountered this error Variable 'dsNewRow' is used before it has been assigned a value. A null reference exception could result at runtime when i click on the button to insert data into my ms access database.
here is my code :
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
da.Fill(ds, "db1")
txt1.Text = ds.Tables("db1").Rows(0).Item(1)
dsNewRow.Item("text") = txt1.Text
dsNewRow = ds.Tables("db1").NewRow()
ds.Tables("db1").Rows.Add(dsNewRow)
da.Update(ds, "db1")
MsgBox("New Record added to the Database")
End Sub
can anyone help me? thnks in advance!!
regards,
charles
i have encountered this error Variable 'dsNewRow' is used before it has been assigned a value. A null reference exception could result at runtime when i click on the button to insert data into my ms access database.
here is my code :
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
da.Fill(ds, "db1")
txt1.Text = ds.Tables("db1").Rows(0).Item(1)
dsNewRow.Item("text") = txt1.Text
dsNewRow = ds.Tables("db1").NewRow()
ds.Tables("db1").Rows.Add(dsNewRow)
da.Update(ds, "db1")
MsgBox("New Record added to the Database")
End Sub
can anyone help me? thnks in advance!!
regards,
charles