i have a stored procedure
ALTER PROC TESTLOGIN
@UserName varchar(50),
@password varchar(50)
As
Begin
declare @return int;
set @return = (S
2 things.
The query has to complete on sql server before the return value is sent.
The results have to be captured and then finish executing before the return value gets to the object.
In English, finish the work and then retrieve the value.
this will not work:
cmm.ExecuteReader();
int i = (int) cmm.Parameters["@RETURN_VALUE"].Value;
This will work:
SqlDataReader reader = cmm.ExecuteReader();
reader.Close();
foreach (SqlParameter prm in cmd.Parameters)
{
Debug.WriteLine("");
Debug.WriteLine("Name " + prm.ParameterName);
Debug.WriteLine("Type " + prm.SqlDbType.ToString());
Debug.WriteLine("Size " + prm.Size.ToString());
Debug.WriteLine("Direction " + prm.Direction.ToString());
Debug.WriteLine("Value " + prm.Value);
}
if you are not sure check the value of the parameter before during and after the results have been processed by the reader.