Small Problem # 99999999

liquidspaces

Well-known member
Joined
Nov 19, 2002
Messages
74
Location
Richmond, VA
Ok. So all of you have been very helpful thus far. Ive learned a lot. I owe each of you half of my paycheck. BUT I have one more problem in what has become a large series of problems.

Im trying to find and edit a specific record in a database. The table name is Shipping and the field is SHIP_FROM. The record number (which is the primary key) is stored in "lblBOLN.text". My code is below:




Dim objRow As DataRow

objRow = DataSet21.Tables("Shipping").Rows.Find(Val(lblBOLN.Text))

objRow.Item("SHIP_FROM") = txtName.Text



When I execute this, it gets hung up on the above line. I receive the following error:

"Object reference not set to an instance of an object."

Also, when I run the debugger, it shows that the value of objRow is "NOTHING".

If you could offer any help on this I would appreciate it. Maybe Rows.Find isnt doing what I think its doing.



Thanks,

Kevin
 
But thats what I dont understand. Ive double, triple, and quadruple checked to make sure that the row its "looking" for is actually in the database.

Is there a better way to edit the fields of a specific row?
 
Hmm.. from the object browser..

Public Function Find(ByVal key As Object) As System.Data.DataRow
Member of System.Data.DataRowCollection

Summary:
Gets the row specified by the primary key value.

Parameters:
key: The primary key value of the System.Data.DataRow to find.

Return Values:
A System.Data.DataRow containing the primary key value specified; otherwise a null value if the primary key value does not exist in the System.Data.DataRowCollection .

As far as I can tell you are using it correctly, except that youre passing in an integer value which should be fine because itll just box the value into an object. To avoid that overhead just pass in the lblBOLN.Text. Honestly if anything is causing the error it would be that (although I dont see why). Otherwise, what Divil said.. the key just doesnt exist. Make sure you are looking for the key in the correct table and database :)

Then again Im not familiar with database stuff in .NET, so there could be something obvious that Im missing that you can probably see just from the info. I pasted from the object browser.

When all else fails, consult the object browser. *nod*
 
Back
Top