Hi ,
Check this Example will guide you
create proc usp_test_Insert
(@OrderAmount int , @date datetime)
as
begin
insert into dbo.Orders
( OrderAmount, [date])
values
(@OrderAmount ,@date)
select SCOPE_IDENTITY()
end
protected void Button1_Click(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString))
{
con.Open();
using (SqlCommand cmd = new SqlCommand("usp_test_Insert",con))
{
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@OrderAmount",TextBox1.Text);
cmd.Parameters.AddWithValue("@date", DateTime.Now);
int ID = Convert.ToInt32( cmd.ExecuteScalar());
Response.Write("<script>alert('"+ID.ToString()+"')</script>");
}
}
}
Best Regards
M.Mitwalli