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

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.
 
G

Guest

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
 
G

Guest

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.
 
G

Guest

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/
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top