Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling SProc that Returns output Parameters
Message
De
08/07/2005 16:14:08
 
 
À
08/07/2005 11:20:37
John Darragh
Entrotech Engineering, Inc.
Torrance, Californie, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01030503
Message ID:
01030718
Vues:
28
John,

Try running .ExecuteNonQuery() instead of ExecSprocScalar().

~~Bonnie



>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,
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform