Here is my stored procedure:
[dbo].[DFW_Completed_Safety] (
@StartDate VARCHAR(10),
@Station VARCHAR(50),
@EmployeeID INT)
When I code the following:
SqlDataAdapter daAC_CSM = new SqlDataAdapter();
DataSet dsAC_CSM = new DataSet();
try
{
using (SqlConnection sqlConnection = new SqlConnection(connectionString))
{
sqlCmd = new SqlCommand();
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.Connection = sqlConnection;
sqlCmd.CommandTimeout = 0;
sqlCmd.CommandText = "DFW_Completed_Safety";
sqlCmd.Parameters.AddWithValue("@StartDate", startdate);
sqlCmd.Parameters.AddWithValue("@Station", station);
sqlCmd.Parameters.AddWithValue("@EmployeeID", "0");
daAC_CSM.SelectCommand = sqlCmd;
daAC_CSM.Fill(dsAC_CSM);
}
return dsAC_CSM;
}
catch (Exception)
{
throw;
}
it throws the Exception: EmployeeID is received as a varchar.
Conversion failed when converting the varchar value 'd ' to data type int.
Things I tried:
1- Many others post on StackOverflow suggested that Convert.ToInt32(0);
would do it. Since 0 is an Int32 by default, this isn't a solution.
2- Changing the method to receive varchar (send "0") and it doesn't work too.
Thanks for any ideas! (would be greater to keep the method signature to Int).
UPDATE: The question isn't answered yet, since changing my stored procedure to varchar didn't make it.. Any ideas?