Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling a Stored Procedure with Output Parameter
Message
 
 
To
26/06/2010 08:35:11
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01470620
Message ID:
01470705
Views:
34
>>>
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform