This Dataset is going to be the death of me!!! Please Help

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

Guest

I am trying to update a database table through this dataset. The error is
ambigous: "System.NullReferenceException: Object reference not set to an
instance of an object." I have tried replacing the variable "month" with a
string and I tried replacing "ProductList.ToString()" with a string but I
still get the error:


Me.sqlDataAdapter1.Fill(DataSet1, "Queue")

Dim QueueRow As DataRow
QueueRow = DataSet1.Tables("Queue").Rows.Find(myCustomerID)
Me.sqlDataAdapter1.Update(DataSet1, "Queue")

Please Help!

Thanks, Justin.
 
Justin said:
(abridged) I have tried replacing the variable "month" with a
string and I tried replacing "ProductList.ToString()" with a string but I
still get the error:
What is the value of the month variable? It looks as if you're trying to
change the value of the "month" column in the DataRow. If so you must
place quotes around the word "month". Like this:
QueueRow("month") = ProductList.ToString()

Anders Norås
http://dotnetjunkies.com/weblog/anoras
 
month is a string variable representing a table column to save the data to, I
have tried replacing this with a static column string but I still get the
same error.
 
Justin said:
month is a string variable representing a table column to save the data to, I
have tried replacing this with a static column string but I still get the
same error.
Ok, then I suspect that the statement
DataSet1.Tables("Queue").Rows.Find(myCustomerID) evaluates to null. If
this is the case, the ensuing statement will cause an
NullReferenceException. You can place an assertion in your code to
display a message if the QueueRow is null.

The following statement check whether QueueRow is null and outputs a
message if it is:
Debug.Assert( Not (QueueRow Is Nothing), "QueueRow parameter is null",
"Can't get object for null type")

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
 
Back
Top