Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling a Stored Procedure with Output Parameter
Message
 
 
À
26/06/2010 08:35:11
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01470620
Message ID:
01470705
Vues:
35
>>>
public void TestOutputParams()
>>>{
>>>   // Create the parameter and set the direction
>>>   IDbDataParameter param1 = this.CreateParameter("@result", 0);
>>>   param1.Direction = ParameterDirection.Output;
>>>
>>>   // Call the stored procedure and pass the parameter
>>>   IDbCommand cmd;
>>>   this.ExecSprocScalar("OutputParamTest", out cmd, param1);
>>>
>>>   // Retrieve the value from the command object
>>>   IDbDataParameter param = (IDbDataParameter)cmd.Parameters["@result"];
>>>   int x = (int)param.Value;
>>>}
>>
>>It looks to me as a bug in the Help file (incorrect Help). Search for a better example (and preferably using SQLParameter in the Help). That particular piece of code is wrong - (at least last 2 lines seem wrong to me - you already declared parameter - just get it).
>>
>>So, if you want to use that particular sample - comment out the extra declaration and use param1 instead of param at the end.
>
>Thanks,
>
>I've tried that and it didn't make a difference, I still just get 0 as the parameter value.

In the code above, where do you set cmd?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform