I have to save this data in two tables of database There is a form with name and employee id(textbo

Posted by Sp under ASP.NET on 7/31/2012 | Points: 10 | Views : 1700 | Status : [Member] | Replies : 1
I have to save this data in two tables of database

There is a form with name and employee id(textboxes)
and a grid containing all skills of employee like .net, sql etc
Now when i click on save button then ...In table1: we have to save employee id and name and in Table2 we
save employee id and skills so, the table2 contains rows as
1 .net
1 sql
1 javascript
2 .net
2 jquery

How to do this... please guide..




Responses

Posted by: Oswaldlily on: 7/31/2012 [Member] Starter | Points: 25

Up
0
Down

For table1: empid name
in storedprocedure include
ALTER procedure [dbo].[sampledb_sp]
(
@id int
,@name varchar(10)
)
as
begin
insert into table1(empid,name) values (@id,@name)
end
Under save button click
{
string _id="";
string _name="";
_id=txtempid.Text;
_name=txtempname.Text
sampledb_sp(_id,_name) //calling storedprocedure
}
Thus Table1 inserted

table2: empid empskills

foreach(GridViewRow gvr in gv.Rows)
{
string _id = ((System.Web.UI.WebControls.Label)gvr.FindControl("lblempId")).Text;//coming from grid
string _skills = ((System.Web.UI.WebControls.Label)gvr.FindControl("lblempskills")).Text;//this too cumin from grid
}
sampledb2_sp(_id,_skills)//call storedprocedure

in stored procedure
ALTER procedure [dbo].[sampledb2_sp]
(
@id int
,@skills varchar(10)
)
as
begin
insert into table1(empid,empskills) values (@id,@skills)
end


Sp, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response