Updatecommand error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello

In wrote this in VB code:
DAComent.UpdateCommand.CommandText = "UPDATE coment SET estmensag='P' WHERE
nomepess LIKE '%" & Trim(TextBox2.Text) & "%' AND emailpess LIKE '%" &
Trim(TextBox3.Text) & "%' AND mensagpess LIKE '%" & Trim(TextBox5.Text) & "%'"
DAComent.UpdateCommand.ExecuteNonQuery()

....and a error ocurs:"Object reference not set to an instance of an object"

Whats that?

Thanks
 
Vitorjol - Like Sahil mentions, one of the objects isn't instantiated.
Before each one , put in Debug.Assert and test for Is Nothing. However I
think it DAComment was null then you'd be getting the exception on the first
line, not the second one.

however do yourself a favor and lose the Dynamic SQL - it will come back to
bite you if you don't.

Also, if you're using a DataAdapter to handle your updates (particularly if
you used it for Select statements), then you may want to just call
DAComent.Update(DataTableName)
 
Back
Top