在数据网格中填充外键字段的列 [英] fill the foreign key field’s column in the data grid

查看:88
本文介绍了在数据网格中填充外键字段的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我是C#的初学者,所以请耐心等待.
我有两个连接的表,我通过向表中添加文本框,像往常一样用数据填充了第一个表(使用主键),依此类推..我没有问题,但是问题出在第二个表–子项上-(与外键连接),它连接到gridview.如何填充数据网格中外键字段的列,换句话说,如何将主键值从form1的第一个表传递到外键字段表格2的gridview列.
任何帮助将不胜感激.

Hi I’m a beginner in C#, so I would to be patient with me please.
I have two connected tables, I filled the first one (with primary key) with data as usual by adding textboxes to a form and so on.. .I have no problem with it, but the problem is with the second one –the child- (of Foreign key) which is connected to gridview.How can I fill the foreign key field’s column in the data grid, in other words , how can I transfer the primary key value from the 1rst table in the form1 to the foreign key field''s column of gridview in the 2nd form.
Any help would be greatly appreciated.

推荐答案



为此,您必须在两个表中都插入值

做这个

1:在包含主键的表中插入值
2:检索刚插入的数据(通过选择查询,例如,从表名中选择* * anyfieldonform ="value")

3:将所需的数据插入包含外键的表中
Hi,

For this you''ll have to insert values in both tables

do this

1: insert values in table containing Primary Key
2: Retrieve data that you just inserted(by select query for eg select * from table name where anyfieldonform = ''value'')

3: insert the required data into the table containing foreign key


这篇关于在数据网格中填充外键字段的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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