Output & return parameters using SQLHelper from DAAB

From: JStemper (JStemper_at_discussions.microsoft.com)
Date: 11/22/04


Date: Mon, 22 Nov 2004 15:09:07 -0800

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 ____________________________________________



Relevant Pages

  • Return parameter probl with DAAB
    ... When the stored proc is run from Query ... Analyzer it returns both the output parameter and the return value. ... SqlParameter paramEventLocationId = new SqlParameter ("@intEventLocationId", ... int temp = Convert.ToInt32; ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Output & return parameters using SQLHelper from DAAB
    ... > the return value from a stored proc. ... > SqlParameter paramEventLocationId = new SqlParameter ... > int temp = Convert.ToInt32; ...
    (microsoft.public.data.ado)
  • A value copy, not reference, of SqlParameter?
    ... Dim param() As SqlParameter = New SqlParameter ... The stored proc has an OUTPUT parameter which will ... MyStoredProc's @Something parameter is an OUTPUT parameter, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Stored procedure with output parameter
    ... Yor are right Marc, the parameter is updated with the output ... parameter's value from the stored proc. ... SqlParameter param1=new SqlParameter; ... I get an error saying that the proc expects a parameter ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Looking for SQL2K Stored Procedure utility
    ... I would suggest checking out CodeSmith. ... Or at least a google search for "Code Generator". ... i.e. if you have stored proc had 5 params it would generate some text you ... SqlParameter passwordParam = new SqlParameter("@Password", ...
    (microsoft.public.dotnet.framework.adonet)