Skip to content

Null reference exception when trying to use DataAdapter Update

webbsk

Asked Jul 19, 2006, 11:10 AM EDT1 answer
Share
LinkedInX
I keep getting an exception when I call the DataAdapter Update method. I have been trying to figure out what is causing the null reference exception for this code for what seems like forever. The exception information has not been helpful. All it says is: "Object reference not set to an instance of an object." Does any one have any idea what is going on here or how to go about finding out? Any suggestions would be appreciated: I don't even know how to figure out which reference is null!

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Not sure what is causing it, but I've hit that a few times, and can usually resolve it easily:

    1) Assure that the table you are updating has the primary key set.

    2) on tableadapter, delete all fields then right-click and re-run "Configure..." (aside from unchecking Fill a Table, it should just be stepping through the defaults

    3) on tableAdapter re-configure the update method.

    4) right-click on teh update method and test by running "preview data."

    If that doesn't work now, I don't know. Make sure the SQL works, and test from a fresh XSD file.

    (BTW I think these tableAdapters are awesome. if I add a new param to a proc, just refresh as above then rebuild and compiler finds where the new param needs to be added.)

    Kim
    0