具有三个datagridviews的Windows窗体 [英] Windows form with three datagridviews

查看:74
本文介绍了具有三个datagridviews的Windows窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有三个datagridviews的Windows窗体,其中显示了来自SQL Express Server数据库的三个独立表的数据. datagridviews都有自己的数据适配器,数据绑定和命令生成器,并且有两个与表相关的关系.我有添加行的事件的事件处理程序,并且所有三个datagridviews的行离开.我的问题是,当我向主表中添加一行时,行又被添加到其他两个表中.我应该等到输入所有数据后再将记录插入数据库中还是插入到master之后,然后child1然后child2? Master和child1在主/外键字段上相关. Child1和child2的关联方式相同.通过阅读此博客以及其他人在做什么,我已经走到了这一步,但我不想搞砸这个动作.感谢您提供的任何建议!

Everett

I have a Windows form with three datagridviews showing data from three separate tables of a SQL Express Server database. The datagridviews all have their own dataadapter, databinding and command builder, and there are two relations relating the tables. I have event handlers for the row added event and the row leave for all three datagridviews. My question is when I add a row to the master table rows get added to the other two. Should I wait until all data is entered to insert the records to the database or insert to master then child1 then child2? Master and child1 are related on a primary/foreign key field. Child1 and child2 are related the same way. I have gotten this far by reading this blog and what others are doing but I don''t want to mess this action up. Thanks for any advice you can provide!

Everett

推荐答案

在输入数据之前,请不要输入数据.如果您有父级数据,但没有子级数据,那么您无需在子级上输入任何内容,除非要求每个父级都有一个孩子(这是奇数).如果使所有三个表以1对1的关系对代码工作很重要,那么您需要一次插入所有三个表.
You should not enter data until you have it. If you have the parent data, but not the child, then you have nothing to enter on the child level, unless it''s required that each parent has one child ( which is odd ). If having all three tables in a 1 to 1 relationship is important for your code to work, then you need to insert all three at once.


这篇关于具有三个datagridviews的Windows窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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