Calling stored procedures in C # (chapter III)

Source: Internet
Author: User

I graduated from the university so far more than a year, the work encountered a lot of problems, thanks to the blog Park Brothers and sisters selfless sharing, thank you!

The following may have errors and omissions, please give us a lot of advice.

C # Background code is as follows:

//method of calling stored procedure 
public static void Startupworkflow (String firstnodename, String secondnodename, String firstact)
{
SqlConnection conn = new SqlConnection (configurationsettings.appsettings["diconnectionstring "]);
Conn. Open ();
SqlCommand COMM = conn. CreateCommand ();

//startupworkflow is the name of the stored procedure in SQL
Comm.commandtext = "Startupworkflow";
Comm.commandtype = CommandType.StoredProcedure;

//stored procedure parameters
SP = Comm. Parameters.Add ("Firstnodename", SqlDbType.VarChar, 50);
sp. Value = Firstnodename;
SP = Comm. Parameters.Add ("Secondnodename", SqlDbType.VarChar, 50);
sp. Value = Secondnodename;
SP = Comm. Parameters.Add ("Firstactname", SqlDbType.VarChar, 50);
sp. Value = Firstact;
Comm. ExecuteNonQuery ();
}

The SQL statements are as follows:

ALTER  PROCEDURE startupworkflow (@FirstNodeName  varchar, @SecondNodeName varchar, @FirstActName varchar (50))
As
--do something

This way you can call the stored procedure in the background.

Calling stored procedures in C # (chapter III)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.