I just want to call a stored procedure while working with Visual c#
2005 Express Edition and SQL Server
Here is my PressButton method and the subsequent method:
//pick up the date from the user
DateTime = this.dateTimeDatum.Value;
string str = dt.ToShortDateString();
//execute the stored procedure - it gets DateTime as parameter
string commandText = "Exec DBName..ProcessProcedure_Step1 '" +
DateTime.Parse(str) + "'";
string result = dal.ProcessProcedure(commandText);
MessageBox.Show(result);
My ProcessProcedure
int returnedRows = 0;
string result = "";
SqlCommand command = new SqlCommand();
command.Connection = this.connection;//Connection already instantiated
command.CommandType = System.Data.CommandType.StoredProcedure;
command.CommandText = CommandText;
command.CommandTimeout = 5000;
try
{
connection.Open();
returnedRows = command.ExecuteNonQuery();
result = "Execution successful...";
connection.Close();
}
catch (SqlException ex)
{
result = " SQLException: " + ex.Message;
}
Immediately it commes to command.ExecuteNonQuery(), it jumps into the
catch exception area with the message - Stored Procedure not found...
Is there any tricks I am missing?
Thanks in advance