Return parameter probl with DAAB

G

Guest

I'm having trouble getting the following code to return an output value and
the return value from a stored proc. When the stored proc is run from Query
Analyzer it returns both the output parameter and the return value. But when
I use DAAB 2.x the values are both set to 0 which are not the correct values.

TIA John


_C# code _________________________________________________________
SqlParameter paramEventLocationId = new SqlParameter ("@intEventLocationId",
SqlDbType.Int );
SqlParameter paramNewPaymentId = new SqlParameter ("@intNewPaymentID",
SqlDbType.Int, 4 );
SqlParameter paramReturn = new SqlParameter ("@intError", SqlDbType.Int );

paramReturn.Direction = ParameterDirection.ReturnValue;
paramNewPaymentId.Direction = ParameterDirection.Output;

paramEventLocationId.Value = 361;

try
{
SqlHelper.ExecuteScalar(
CONN_STRING,
spName,
paramEventLocationId,
paramNewPaymentId
);
}
catch (Exception ex)
{
ExceptionManager.Publish(ex);
}
int temp = Convert.ToInt32(paramReturn.Value);
int lOrderNumber= Convert.ToInt16(paramNewPaymentId.Value);

_____End Code ____________________________________________
 
G

Guest

Since you don't show your code in SqlHelper.ExecuteScalar, it's hard to say
what is wrong.
 
G

Guest

SqlHelper.ExecuteScalar is a method in the Data Access Application Block. I
have not made any changes to that code.

John
 
E

EltonW

You should explicitly specify StoredProcedure parameter:
SqlHelper.ExecuteScalar(CONN_STRING,
System.Data.CommandType.StoredProcedure, spName,
paramEventLocationId,
paramNewPaymentId
);
BTW, it is better to use ExecuteNonQuery method rather
than ExecuteScalar method in your case.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top