I have a sample code
aCommand.CommandType = CommandType.StoredProcedure;
aCommand.Parameters.AddWithValue("@book_id", bookID);
aCommand.Parameters.AddWithValue("@user_id", userID);
and after that I want to execute a simple query using CommandText
:
aCommand.CommandText = "SELECT * FROM aTABLE";
aCommand.ExecuteNonQuery();
but the error occurs:
Exception: Could not find stored procedure 'SELECT * FROM aTABLE'
In this case, I have to create a new instance of SqlCommand
object ?
It is a way to use same SqlCommand
object to avoid create one ?
It should be
aCommand.CommandType = CommandType.Text
actually, the default value of CommandType
is CommandType.Text
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With