SqlDataAdapter.Update不起作用 [英] SqlDataAdapter.Update doesn't work

查看:465
本文介绍了SqlDataAdapter.Update不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用SqlDataAdapter.Update(数据表)抛出一个表的数据库,但SqlDataAdapter的忽略我的InsertCommand写自己的,只发送的主键,所有可以为空,如果他们想要的行。我如何得到它的行为?

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?

我步前的code和我所说的更新后()。之前,这是我的InsertCommand。之后,它的的SqlDataAdapter的。

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

编辑:我并不特别要张贴code的样品,因为我可以把该行我已经和写我自己的SqlCommand对象,它的工作原理很轻松了。我更感兴趣的原因更新将决定将InsertCommand我通过它不够好,所以我可以通过我自己的code挖 - 这整个事情应该是一个节省时间

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.

推荐答案

权,大量的挖我发现我需要打电话给EndEdit中对我行的时候,我跟他们这样做的我做了没有被更改后由数据表丢弃。正如我所说,我没有做任何其他比调用SqlDataAdapter.Update(数据表)。

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

这篇关于SqlDataAdapter.Update不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆