Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling SProc that Returns output Parameters
Message
De
08/07/2005 11:20:37
John Darragh
Entrotech Engineering, Inc.
Torrance, Californie, États-Unis
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Calling SProc that Returns output Parameters
Divers
Thread ID:
01030503
Message ID:
01030503
Vues:
90
I'm trying to call an MS SQL stored proc that returns a value via an output parameter. The procedure executes, but I'm not getting the output parameter back to my app.

I'm attempting to call this proc to get a sequence number from within the HookSetDefault handler in a Business Object like this:
Protected Overrides Sub HookSetDefaultValues(ByVal dataRow As System.Data.DataRow)
        Dim cmd As IDbCommand

        If Not (Me.DefaultValues Is Nothing) Then
            ' Cast the DefaultValues object to the custom type
            Dim Defaults As ContactDefaultValues = CType(Me.DefaultValues,
                    ContactDefaultValues)

            ' Store the default values in the new DataRow
            dataRow("idEntityType") = Defaults.idEntityType
            dataRow("idMaritalStatus") = Defaults.idMaritalStatus
           
            ' Go to the database to get the new contact's sRefNum
            ' This way, the user knows the Ref Num before the contact is saved at all.
            Dim param1 As IDbDataParameter = Me.CreateParameter("@idSeqType", 4)
            Dim param2 As IDbDataParameter = Me.CreateParameter("@idContact", 1)
            Dim param3 As IDbDataParameter = Me.CreateParameter("@sValue", "dogfood")
            param3.Direction = ParameterDirection.Output
            Dim params As IDbDataParameter() = {param1, param2, param3}

            Me.ExecSprocScalar("CalcSeqNum", cmd, params)
            Dim paramOut As IDbDataParameter = CType(cmd.Parameters("@sValue"),
                   IDbDataParameter)
            dataRow("sRefNum") = paramOut.Value.ToString   
        End If

    End Sub
This code runs, and the procedure executes, but the paramOut.value.ToString returns "", instead of the value that the stored procedure actually returned.

If I run the sproc from Query Analyzer, it runs fine.

Any ideas?

Thanks,
John Darragh
Entrotech Engineering, Inc.
darragh@entrotech.net
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform