使用范围标识值如何将多行插入到其他表中 [英] using scope identity value how to insert multiple rows into other table

查看:56
本文介绍了使用范围标识值如何将多行插入到其他表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表tblinvoice,我通过使用范围标识关键字获得最新生成的身份标识。



现在我想使用此范围标准值插入多行在其他表中,所有记录都有相同的id(作为外键的范围标识)。





任何人告诉我它是如何可能的asp.net

i have one table tblinvoice by which i got latest generated identity id via using scope identity keyword.

Now i want to use this scopeidentity value to insert multiple rows in others table with all records have same id(scope identity as foreign key).


any one tell me how it is possible in asp.net

推荐答案

如果我做对了,你正在进行SQL插入,你得到了id并根​​据你想要将其他行插入另一个表的id ?



只需使用SqlCommand插入数据。



如果您有大量数据需要考虑关于批量操作。



你也可以使用SqlAdapter与你的数据库同步数据。



如果你想要了解更多关于这个主题的信息

试试这个例子:为初学者使用ADO.NET [ ^ ]



或只是google ADO.NET或c#SQL或者像这样的一些想法。如果你有更具体的问题,请问我会尽力帮助:)
If I get it right, you are making SQL insert, you get back id and based on that id you want to insert other rows into another table?

just use SqlCommand to insert data.

if you have a lot of data you should think about batch operations.

you can also use SqlAdapter to synchronize data with your database.

if you want to know more about this topic
try for example this: Using ADO.NET for beginners[^]

or just google ADO.NET or c# SQL or somethink like this. If you have more specific question, just ask I will try to help :)


这篇关于使用范围标识值如何将多行插入到其他表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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