Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling a Stored Procedure with Output Parameter
Message
From
27/06/2010 09:24:30
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01470620
Message ID:
01470715
Views:
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?

Naomi, it is passed into the mm method and gets created there by the concrete implementation, in this case a SQL concrete class.
Tim
Timothy Bryan
Previous
Reply
Map
View

Click here to load this message in the networking platform