Calling a stored procedure from ASP.NET c# website/application

Hello All,

To call a stored procedure you need to set CommandType property of SQLCommand to CommandType.StoredProcedure. Following is the sample code for the same:-

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["<<YourConnectionStringKey>>"].ToString());
SqlCommand cmd = new SqlCommand();
SqlDataAdapter da = new SqlDataAdapter(); 
	cmd.Connection = con;
	cmd.CommandText = "<<Stored Procedure Name>>"
	cmd.CommandType = CommandType.StoredProcedure;
 DataSet ds = new DataSet();

Any ?’s, Please let me know. Thanks.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>