以一种形式将数据插入到所有表中 [英] insert data into all the tables at one form
本文介绍了以一种形式将数据插入到所有表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是C#和ASP.NET编程的新手,我创建了一个数据库,其中有6个表通过外键相互连接。
我的问题考虑到他们拥有的外键,我如何一次性将数据插入到所有表中。
i只需要一个示例脚本,该脚本显示如何将数据插入所有六个桌子一次..
提前谢谢你。
i需要一个样本用/>
sqlcommand AND dataset AND linq
你可以假设为northwind db for sample
i am a newbie to C# and ASP.NET programming, i have created a database which has 6 tables connected to each other by foreign keys.
my problem is how do i insert data into all the tables at once considering the foreign keys they have.
i just need a sample script which shows how to insert data into all the six tables at once..
thank you for your in advance.
i need a sample with
sqlcommand AND dataset AND linq
you can Supposed northwind db for sample
推荐答案
你不能。您一次只能插入一个表。诀窍是首先为顶级记录执行插入,检索该记录的ID,然后使用它来为其他表执行插入。
You can''t. You can only INSERT into one table at a time. The trick is to do the insert for the top-level record first, retrieve the ID of that record, then use that to do the inserts for the other tables.
这篇关于以一种形式将数据插入到所有表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文