本文介绍了如何插入多行(一对多关系)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表由一对多关系链接,

第一个表是(Bill's),第二个是(Bill详情)



来自C#WinForms我想在Bills表中插入一条记录,并将多条记录插入到Details表中

使用存储过程和WindowsForm照常发送的参数



我尝试了什么:



i试图使用sqlcommand将单个记录插入账单表

然后使用for循环执行另一个sqlcommand在详细信息表中插入多个记录链接到上一个表(一对多)关系

但是有没有更好的方法要做那个还是那个唯一的方法?

I've two tables linked by one to many relation,
first table is (Bill's) and the second is (Bill details)

From C# WinForms i want to insert one record into Bills table and multiple records into Details table
using a stored procedure and parameters sent from the WindowsForm as usual

What I have tried:

i tried to use a sqlcommand to insert single record into "bills table"
then use a "for" loop to execute another sqlcommand to insert multiple records in details table linked to the previous table(One to many) relation
But is there a better way to do that or that's the only way?

推荐答案


这篇关于如何插入多行(一对多关系)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 18:42