Call stored procedure in Asp.Net using C#.Net

This asp.net tutorial explains, how to call a stored procedure in asp.net using C#.Net code. In this example, it will take one input parameter as empid and will return the result records for the particular empid.

Call stored procedure in Asp.Net using C#.Net

Below is the full code to Call stored procedure in Asp.Net using C#.Net.

string connectionString = "Your connection string goes here!";
SqlConnection con = new SqlConnection(connectionString);
SqlCommand cmd = new SqlCommand("SP_NameOfYourSP", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@empid", SqlDbType.Int).Value = 12345;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
try
{
con.Open();
da.Fill(ds, "Authors");
}
catch (Exception ex)
{
throw;
}
finally
{
con.Close();
}

You may like following asp.net and c#.net tutorials:

Hope this asp.net tutorial helps to Call stored procedure in Asp.Net using C#.Net.

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>