How do u call and execute a stored procedure in .NET?

  • tags:
Author Profile

author

sandeep

@sandeep

Answers

For calling stored procedure from sql server this method can be used:


SqlCommand cmd = new SqlCommand("[Usp_Save]", con);
cmd.CommandType = CommandType.StoredProcedure;

cmd.Parameters.Add("@Title", SqlDbType.NVarChar).Value = txtTitle.Text.Trim();
cmd.Parameters.Add("@Descr", SqlDbType.NVarChar).Value = txtDesc.Text;

con.Open();
cmd.ExecuteNonQuery();
con.Close();


Solution #1

Leave a Comment

message*