hi,
there is no need of 2 storedprocedure
create 2 table
personal
id-int primary key
age-int
name -varchar
and another table
official
id -int primary key
dept -varchar
sal -int
stored procedure
create procedure testtables
@id int,
@name varchar(50),
@age int,
@dept varchar(50),
@sal int
as
insert into personal(id,[name],age)values(@id,@name,@age)
insert into official(id,dept,sal)values(@id,@dept,@sal)
next i am writing the code in button's click event
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=BAIJU;Initial Catalog=baiju;Integrated Security=True");
SqlCommand cmd = new SqlCommand("testtables", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@id", TextBox1.Text);
cmd.Parameters.AddWithValue("@name", TextBox2.Text);
cmd.Parameters.AddWithValue("@age", TextBox3.Text);
cmd.Parameters.AddWithValue("@dept", TextBox4.Text);
cmd.Parameters.AddWithValue("@sal", TextBox5.Text);
try
{
con.Open();
cmd.ExecuteNonQuery();
Label1.Text = "Added successfully";
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
finally
{
con.close();
}
}
this is working fine
any way if it work or any problem
write to me
KLBAIJU@YAHOO.CO.IN
Regards
K L BAIJU
Sumana2net, if this helps please login to Mark As Answer. | Alert Moderator