Sending Parameters to Stored Procedures
Using parameters for stored procedures is the same as using parameters for query string commands. The following code shows this:
// 1. create a command object identifying
// the stored procedure
SqlCommand cmd = new SqlCommand(
"CustOrderHist", conn);
// 2. set the command object so it knows
// to execute a stored procedure
cmd.CommandType = CommandType.StoredProcedure;
// 3. add parameter to command, which
// will be passed to the stored procedure
cmd.Parameters.Add(
new SqlParameter("@CustomerID", custId));
1st and 2nd steps are use to execute stored procedure. And 3rd step is use to provide the suitable parameter according to the stored procedure.
In here we can add Parameters. For that use cmd.Parameters.Add(new SqlParameter(“@param”,xxxx)).
According to above example I have mention above @Variable take single parameter. And we can parse value to that parameter according to our requirement.
Your Comments are highly appreciated; it will be improving my knowledge also.
// 1. create a command object identifying
// the stored procedure
SqlCommand cmd = new SqlCommand(
"CustOrderHist", conn);
// 2. set the command object so it knows
// to execute a stored procedure
cmd.CommandType = CommandType.StoredProcedure;
// 3. add parameter to command, which
// will be passed to the stored procedure
cmd.Parameters.Add(
new SqlParameter("@CustomerID", custId));
1st and 2nd steps are use to execute stored procedure. And 3rd step is use to provide the suitable parameter according to the stored procedure.
In here we can add Parameters. For that use cmd.Parameters.Add(new SqlParameter(“@param”,xxxx)).
According to above example I have mention above @Variable take single parameter. And we can parse value to that parameter according to our requirement.
Your Comments are highly appreciated; it will be improving my knowledge also.



0 comments:
Post a Comment