Last post Jul 13, 2011 07:06 AM by johnny_rambo
Jul 10, 2011 09:31 AM|johnny_rambo|LINK
I'm having a problem executing a select statement. Running the following line of code gives me a "could not find stored procedure" error....
IDataReader reader = command.ExecuteReader();
The command type for the command object is set to Command.Text. Does anyone have any idea why this happening? I've attached a screenshot of the state of the command object just before calling the ExecuteReader method.
Jul 10, 2011 11:46 AM|princeG|LINK
It might problem in you IDatareader
Jul 11, 2011 10:36 PM|decker dong - msft|LINK
Running the following line of code gives me a "could not find stored procedure" error....
1）Please make sure that your Stored Procdure really there in your db.
2）You should call Stored Procdure like this：
SqlConnection nwindConn = new SqlConnection("Data Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind");
SqlCommand salesCMD = new SqlCommand("SalesByCategory", nwindConn);
salesCMD.CommandType = CommandType.StoredProcedure;
SqlParameter myParm = salesCMD.Parameters.Add("@CategoryName", SqlDbType.NVarChar, 15);
myParm.Value = "Beverages";
Jul 13, 2011 07:06 AM|johnny_rambo|LINK
The problem was with the CommandText property. The "\ at the start caused it to treat the command as a stored procedure.