Click here to Skip to main content
15,920,576 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 1 table having no of fields empid as primary key for table1 & for table 2 i used empid as foreign key.I used stored procedure for insert the data. Table 2 having
emp education details with university,yearof passing etc columns.i want to insert the records in table 2 with empid.For that i want stored procedure.
Deatiled view of table

Table1
empid
name
address
mob.no
etc
Table2
empid
university
year of passing
Major subject
all are having 3 textboxes
i want to insert the record from all 3 text boxes to table2 with empid
For that i want stored procedure & vb.net code.


Thanx in advance
Posted
Updated 8-Sep-11 9:21am
v3
Comments
[no name] 8-Sep-11 15:24pm    
hi,
first try your self.

Look at the OUTPUT[^] clause.

After inserting into one table you have information that is needed to insert into another.
 
Share this answer
 
hai

use this stored procedure and try to use insert values in table in your vb code..



drop procedure sp_insert<br />
go<br />
create procedure sp_insert<br />
@p_ename varchar(50),@p_ecity varchar(50),@p_eid bigint,@p_empedu varchar(50),@p_empuni varchar(50)<br />
as <br />
declare @eid int<br />
begin <br />
insert into empinfo(empname,empcity) values(@p_ename,@p_ecity)<br />
set @eid=@@identity<br />
if(@eid!=0)<br />
insert into empstu(empid,empedu,empuni)values(@p_eid,@p_empedu,@p_empuni)<br />
select @eid<br />
end


try it..
i hope this is useful to you..
take care ....
 
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