Techno
Apr 4th, 2006, 08:35 PM
this is a wierd one but hope someone can help
I have a stored proc which returns me nvarchar (50) - the data for this column is something like this:
23vv54sdu4 (or whatever)
the stored procedure works fine as I have ran it in Query Analyzer and the syntax is correct. it gives me the return value (the example data I gave above)
in C#, I am trying to call this stored procedure however I always get this error:
"Syntax error converting the nvarchar value '23vv54sdu4 'to a column of data type int."
but no where have I set the parameters to data type int. Any ideas:
SqlParameter theCustomerIDParam = new SqlParameter("@theCustomerID", SqlDbType.Int);
theCustomerIDParam.Value = theCustomerID;
SqlParameter theReturnResult = new SqlParameter("@theReturnValue", SqlDbType.NVarChar, 50);
theReturnResult.Direction = ParameterDirection.Output;
theSQLCommand.Parameters.Add(theCustomerIDParam);
theSQLCommand.Parameters.Add(theReturnResult);
theSQLCommand.Connection.Open();
theSQLCommand.ExecuteNonQuery(); //error
theSQLCommand.Connection.Close();
I have a stored proc which returns me nvarchar (50) - the data for this column is something like this:
23vv54sdu4 (or whatever)
the stored procedure works fine as I have ran it in Query Analyzer and the syntax is correct. it gives me the return value (the example data I gave above)
in C#, I am trying to call this stored procedure however I always get this error:
"Syntax error converting the nvarchar value '23vv54sdu4 'to a column of data type int."
but no where have I set the parameters to data type int. Any ideas:
SqlParameter theCustomerIDParam = new SqlParameter("@theCustomerID", SqlDbType.Int);
theCustomerIDParam.Value = theCustomerID;
SqlParameter theReturnResult = new SqlParameter("@theReturnValue", SqlDbType.NVarChar, 50);
theReturnResult.Direction = ParameterDirection.Output;
theSQLCommand.Parameters.Add(theCustomerIDParam);
theSQLCommand.Parameters.Add(theReturnResult);
theSQLCommand.Connection.Open();
theSQLCommand.ExecuteNonQuery(); //error
theSQLCommand.Connection.Close();