[VB.Net] Updating oledbdataadapter

  • Thread starter Thread starter Lasse Eskildsen
  • Start date Start date
L

Lasse Eskildsen

Hi,

In vb.net, I have a dataset, which I make changes to. When I add a row and
update the database, it's ok, but when I delete or edit a row, i get the
following errormessage: "Object reference not set to an instance of an
object."
on this line:
OleDbDataAdapter1.DeleteCommand.CommandText = "DELETE FROM Person WHERE
Id='26'"

In short, my update looks like this:

Dim newdataset As New DataSet()
newdataset = DataSet11.GetChanges
Me.BindingContext(DataSet11, "person").EndCurrentEdit()
OleDbDataAdapter1.DeleteCommand.CommandText = "DELETE FROM Person WHERE
Id='26'" 'This is the line!
OleDbDataAdapter1.Update(newdataset, "person")

I hope someone can help me solve this (I've just updated from vb6 to vb.net)
Thanks in advance!
 
Fromk what little I can see, the DeleteCommand hasn't been instantiated. You
could try creating an OleDbCommand object with the CommandText property set
to "DELETE FROM Person WHERE Id='26'" and then assign this command object to
the OleDbDataAdapter1.DeleteCommand.
 
Back
Top