如何以编程方式获取 DataTable 的 TableAdapter?
不确定这是否有意义,但是:
我有一个附加了许多 TableAdapter 的表单(在 VS 中绑定)。
根据用户的选择,DataTable 由其中一个 TableAdapter 填充并传递到另一个表单以在 DataGridView 中显示/编辑。然后如何将对 DataTable 的任何更改保留回数据库?
我需要确定要使用哪个 TableAdapter,以便可以调用它的 Update 方法,但我看不到执行此操作的简单方法。
我有一种可怕的感觉,我把自己编码到了这里的一个角落......
Not sure if this makes sense but:
I have a form with a number of TableAdapters attached (bound in VS).
Depending on user selection, a DataTable is filled by one of the TableAdapters and passed to another form for display/Edit in a DataGridView. How do I then persist any changes to the DataTable back to the database?
I need to identify which TableAdapter to use so that I can call the Update method on it but I can't see an easy way of doing this.
I have a horrible feeling that I've coded myself into a corner here....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这里肯定存在一些设计问题,但听起来它们已经被编码了。为什么不将对 TableAdapter 的引用塞入 DataTable 的 Tag 属性中,然后在准备好后可以转换回它呢?就在我的头顶上。
I think there is definitely some design issues here but it sounds like they have already been coded. Why don't you tuck a reference to the TableAdapter into the Tag property of the DataTable and then when you are ready you can cast back to it? Just off the top of my head.