Hey guys,
This blog we discuss how to write insert code in
asp.net using stored procedure linq to sql query.
Create a table like
Id , Name, City three columns
Create stored procedure like:-
create procedure storedata
(@Id int,
@Name varchar(50),
@City varchar(50)
)
as
begin
insert into mydata(Id ,Name ,City)values(@Id,@Name,@City)
end
protected void
btnSubmit_Click(object sender, EventArgs e)
{
try
{
using (storeDataContext
mystore = new storeDataContext())
{
mystore.storedata(Convert.ToInt32(txtid.Text),
txtname.Text, txtcity.Text);
}
lblMsg.Text = "Successfully
insert data";
}
catch (Exception
er)
{
lblMsg.Text = er.Message;
}
}
No comments:
Post a Comment