i am using a data adapter and a dataset for filling and retrieving data
into .mdb database.
following is the code.....
for the form load event
Dim dc(0) As DataColumn
Try
If OleDbConnection1.State = ConnectionState.Closed Then
OleDbConnection1.Open()
Else
MsgBox("connection can not be established")
End If
DA.Fill(DataSet11, "Table1")
cmd = New OleDbCommandBuilder(DA)
dc(0) = DataSet11.Tables("Table1").Columns("EmpID")
DataSet11.Tables("Table1").PrimaryKey = dc
Catch ex As Exception
MsgBox(ex.Message)
End Try
Delete.Enabled = False
End Sub
for inserting values into the DB
Private Sub Insert_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Insert.Click
Dim dr As DataRow
dr = DataSet11.Tables("Table1").NewRow
dr.Item(0) = Val(TB1.Text)
dr.Item(1) = TB2.Text
dr.Item(2) = TB3.Text
dr.Item(3) = Val(TB4.Text)
dr.Item(4) = TB5.Text
DataSet11.Tables("Table1").Rows.Add(dr)
DA.Update(DataSet11, "Table1")
MsgBox("data is saved")
rno = 0
call filldata()
filldata function consists of the following
With DataSet11.Tables("Table1").Rows(rno)
TB1.Text = Trim(.Item(0))
TB2.Text = Trim(.Item(1))
TB3.Text = Trim(.Item(2))
TB5.Text = Trim(.Item(4))
End With
the error it gives is " there is no row at
0........system.nullreference...........i checked the connection and
its working fine and also the database is getting accessed........the
error is occuring at the line " With
DataSet11.Tables("Table1").Rows(rno) "