[VB.Net] Updating oledbdataadapter

  • Thread starter Lasse Eskildsen
  • 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!
 
C

CT

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top