1

I'm using SqlDataAdapter.Update(DataTable) to throw a table at the database, but the SqlDataAdapter ignores my InsertCommand to write its own, which only sends the primary key and all the rows that can be null if they want. How do I get it to behave?

I step through the code before and after I call Update(). Before, it's my InsertCommand. After, it's the SqlDataAdapter's.

Edit: I don't especially want to post code samples because I can take the row I have and write my own SqlCommand object that works easily enough. I'm more interested in reasons why Update would decide that the InsertCommand I pass it isn't good enough so I can go digging through my own code -- this whole thing was supposed to be a timesaver.

1
  • Can you be more specific as to which bit of the code? I'm not doing anything other than calling SqlDataAdapter.Update(DataTable) once I'm done. Commented May 7, 2009 at 4:38

1 Answer 1

2

Right, after lots of digging I found out that I needed to call EndEdit on my rows when I was done with them so the changes I made weren't being discarded by the DataTable. As I said, I wasn't doing anything other than calling SqlDataAdapter.Update(DataTable).

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, good sir! This is exactly what I needed! BindingSource.EndEdit() before DataAdapter.Update() does the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.