Thanks. In haste, I fogot the following things:
1. Declaring the connection:
SqlConnection Connection = new SqlConnection( connectionString );
2. BuildQueryCommand was my implementation and not part of the framework.
Here is it:
private SqlCommand BuildQueryCommand(string storedProcName, IDataParameter[]
parameters)
{
SqlCommand command = new SqlCommand( storedProcName, Connection );
command.CommandType = CommandType.StoredProcedure;
foreach (SqlParameter parameter in parameters)
{
command.Parameters.Add( parameter );
}
return command;
}
Ram
Kate_Luu said:
Thanks you so much Ram, I couldn't imagine that I got responded so quickly.
I'm deeply appreciated. Take care and have a good evening...
Kate
Ram Dash said:
Roughly it would be like this:
SqlDataReader returnReader;
SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int,
4) };
parameters[0].Value = userID;
Connection.Open();
SqlCommand command = BuildQueryCommand( storedProcName, parameters );
command.CommandType = CommandType.StoredProcedure;
returnReader = command.ExecuteReader();
Connection.Close();
Please check for syntax and other details.
Thanks,
Ram
Hi all Pro,
Are there any body know how to execute store procedure from .cs
file?
any
help is greatly appreciated. Thanks you in advance.
Kate