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

Sign up for an Office 365 SharePoint Online Business Subscription

In this post, we will discuss how to call a stored procedure in 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.
Below is the full code:
       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();
            da.Fill(ds, “Authors”);
        catch (Exception ex)

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site

View all posts by Bijay Kumar →