Conversion failed during calling stored procedure

Tetak

New Member
Here is my stored procedure:\[code\][dbo].[DFW_Completed_Safety] ( @StartDate VARCHAR(10), @Station VARCHAR(50), @EmployeeID INT)\[/code\]When I code the following:\[code\]try{ sqlCon = new SqlConnection(connectionString); sqlCmd = new SqlCommand(); sqlCmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter daAC_CSM = new SqlDataAdapter(); DataSet dsAC_CSM = new DataSet(); sqlCmd.Connection = sqlCon; sqlCmd.CommandTimeout = 0; sqlCmd.CommandText = "DFW_Completed_Safety"; sqlCmd.Parameters.AddWithValue("StartDate", startdate); sqlCmd.Parameters.AddWithValue("Station", station); sqlCmd.Parameters.AddWithValue("EmployeeID", 0); sqlCon.Open(); daAC_CSM.SelectCommand = sqlCmd; daAC_CSM.Fill(dsAC_CSM); sqlCon.Close(); return dsAC_CSM;}catch (Exception ex){ throw ex;}\[/code\]it throws the Exception: EmployeeID is received as a varchar.\[quote\] \[code\]Conversion failed when converting the varchar value 'd ' to data type int.\[/code\]\[/quote\]Things I tried:1- Many others post on StackOverflow suggested that \[code\]Convert.ToInt32(0);\[/code\] 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).
 
Back
Top