如何在4个不同的表中插入数据 [英] How to insert data in 4 different tables

查看:64
本文介绍了如何在4个不同的表中插入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个ASP.NET页面,这个页面显示来自4个不同表格的数据,使用下拉列表和实体数据源之间存在关联....



但问题是如何在这个表中插入这些数据......

I had created an ASP.NET page this page display data from 4 different tables there is a relation between them using drop down list and entity data source ....

but the problem is how to insert this data in this tables......

推荐答案

有多种解决方案可以插入到多个表中。

你可以使用实体框架,LINQ to SQL等来实现。通过存储过程完成它的最佳方法如下所示。





Well there are various solution to insert into multiple tables.
You can do it using entity framework, LINQ to SQL etc. The best way to do it through stored procedure is shown below.


DECLARE @DepartmentID int
 DECLARE @EmployeeId int
 Insert into Table 1(ID,  EmployeeName)value('1','ABC')

 SELECT @EmployeeId=SCOPE_IDENTITY()
 Insert into Table 2( DepartmentName, Location) value('Test','Bangalore')
 SELECT @DepartmentID =SCOPE_IDENTITY()
 Insert into Table 3( EmployeeId ,  DepartmentID ) values(@EmployeeId ,@DepartmentID)


你可以使用商店程序完成这项工作。
you can do this job by using store procedure.


这篇关于如何在4个不同的表中插入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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