Click here to Skip to main content
15,900,108 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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......
Posted

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.


SQL
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)
 
Share this answer
 
you can do this job by using store procedure.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900