by
0
7
2,554
0
Top 1% !
Popular
Famous
Tagged
Easy-to-find
Specified
Refined
Popularity: 6517th place
This snippet is Public
Architecturex86_64
Extension.cs
InputName0connection
InputName1name
InputType0SqlConnection
InputType1string
LanguageCSharp
LicenseMIT_X11
MethodNameCreateStoredProc
OSWindows
OutputTypeSqlCommand
Windows VersionWindows7

How to create a new SqlCommand to invoke a Stored Procedure

This method creates a new SqlCommand for a stored procedure invocation.
It sets all the relevant information for a stored procedure that can be then executed in ADO.NET environment
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/428/How-to-create-a-new-SqlCommand-to-invoke?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
static public SqlCommand CreateStoredProc(SqlConnection connection, string name) { SqlCommand newSPCmd = new SqlCommand(); newSPCmd.CommandType = CommandType.StoredProcedure; newSPCmd.Connection = connection; newSPCmd.CommandText = name; newSPCmd.CommandTimeout = WebConfig.Current.DBConnectionTimeout; //default timeout for snip2code return newSPCmd; }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus