普通插入件和散装插入件 [英] Oridinary insert and bulk insert together

查看:70
本文介绍了普通插入件和散装插入件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须使用该标识值在一个表中插入两个字段,我还必须使用存储过程在另一个表中插入一个数据表,并且还想更新,删除第二个表值.

示例:
表1:

I have to insert two fields in a table using that identity value i have to insert a datatable in another table using stored procedure, and also want to update, delete second table values.

EXAMPLE:
Table1 :

PurchaseID int -> identity field
  VendorName nvarachar(20)



表2:



Table 2:

PurchaseID int
 ItemName nvarchar(20)
 ItemQty  int
 Rate     decimal
 TotalAmount decimal


在文本框中输入的Table1字段值和Table2字段值存储为数据表,并且都传递给sql server存储的porocedure.我该如何有效地做到这一点.请帮帮我.

我需要在SQL Server中不使用xml数据类型的情况下回答吗?


Table1 fields value entered in textbox and Table2 fields values are stored as datatable and both passes to sql server stored porocedure. How can i do this effiecently. Please help me.

I need answer without using xml datatype in sql server?

推荐答案

1)创建一个将接受三个参数的存储过程
PurchaseID INT
VendorName nvarachar(20)
PurchaseDetailsXML XML
2)在表1中插入前两个参数
3)解析XML并将值插入临时表中.然后将这些值也插入表2

4)从C#代码执行存储过程时,您必须将数据表转换为XML值并将其存储在一个XML变量中,例如说"Purdetails"还将ID和供应商名称存储为两个变量"Id","VenName"

然后执行存储过程,并将这三个变量作为参数传递

希望这会有所帮助,
--Rahul
1) Create one stored procedure which will accept three parameters
PurchaseID INT
VendorName nvarachar(20)
PurchaseDetailsXML XML
2) Insert first two parameters in Table1
3) Parse XML and insert the values in temporary table . then insert those values as well in to Table2

4) while executing the stored procedure from C# code you have to convert datatable into XML value and stored that in one XML variable let say "Purdetails" also store id and vendorname into two variable "Id","VenName"

Then execute the stored procedure and pass these three variable as parameter

Hope this helps,
--Rahul


这篇关于普通插入件和散装插入件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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