This article is a mirror article of machine translation, please click here to jump to the original article.

View: 21794|Reply: 3

[WinForm] Call the stored procedure of the database in C#

[Copy link]
Posted on 10/9/2014 9:56:16 AM | | |
1. Call the stored procedure: Replace the string with the stored procedure name.
string strSql =  "proc_transfer";
2. Set the sql script type: sqlComm.CommandType= CommandType.StoredProcedure;
3. Stored procedure with parameters: (the first two steps remain unchanged)
       (1) Define the parameter object to be passed into the stored procedure: SqlParameter
              SqlParametersqlPara = new SqlParameter("The name of the parameter in the stored procedure", The type of data in the database);
         sqlPara2.Value = outID;    //putc #into the parameter object
                   2) to put the previous parameter object incommandGo inside
                   sqlComm.Parameters.Add(sqlPara);
                   3The next step remains the same: letcommandexecute
         4.Stored procedures with output parameters
                   1Than31One more sentence: set a property so that the object of the parameter becomes the output parameter
                   sqlPara.Direction = ParameterDirection.Output;
                   2With32) is the same
                   3With33) is the same
                   4Get the output parameter: Get the value in the output parameter
                   stringmess = sqlPara4.Value.ToString();





Previous:The simulated bread has arrived, fragrant, and the prize puppet of forum No. 15!
Next:Detailed explanation of sqlserver creating stored procedures
Posted on 9/24/2019 4:46:47 PM |
Thank you for the paving
Posted on 9/24/2019 4:52:07 PM |
Thank you, landlord...
Posted on 9/24/2019 4:59:41 PM |
WD thank you landlord
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com