SqlDataAdapter.Update doesn't work

て烟熏妆下的殇ゞ 提交于 2019-12-23 03:12:59

问题


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:


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



来源:https://stackoverflow.com/questions/832874/sqldataadapter-update-doesnt-work

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!