cbeebe79

cbeebe79

  • NA
  • 6
  • 0

Specified Cast not Valid.. Stored procedure

Jun 5 2010 7:48 PM
Hi.

Simple question:  I have a stored proc that has an output of @oRetVal.

I have it coded as such:

sql.Parameters.Add("@oRetVal", SqlDbType.Int).Value = 0;
              
sql.Parameters["@oRetVal"].Direction = ParameterDirection.Output;


After I execute the proc I have:

int retVal;

retVal = (int)sql.Parameters["@oRetVal"].Value;


But I am getting the error:  "Specified cast is not valid"


I am not sure what the issue is.  The variable is created as an int and the actual param is an int.  What am I doing wrong here?

Thanks


Answers (2)