Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
ExecSprocScalar and catch my return value
Message
De
24/04/2006 20:21:20
 
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Divers
Thread ID:
01115912
Message ID:
01116156
Vues:
12
Oooooh, my bad! I didn't notice this was an MM question ... yeah, someone else is gonna have to give you a hand with this. I have no clue how Kevin handles this. Sorry! =(

~~Bonnie




>>Hi Stephen,
>>
>>I get the feeling that you're mixing and matching where you shouldn't be. If you are indeed running the ExecuteScalar() method, what it returns to you is the first column of the first row of the result set returned by the query. But since it looks like you're trying to use parameters to return the RONumber, I'm guessing that this is not what you were expecting ExecuteScalar() to do. If you want to use OUTPUT parameters, they need to be specified as OUTPUT parameters in your Stored Proc and you need to use the Parameter.Direction property to set the direction appropriately (Output or InputOutput). (Also, you didn't say what backend database you're using and whether or not it supports output parameters in Stored Procs.)
>>
>>~~Bonnie
>This is the query from SQL-Server
>
>Declare @ret int
>exec Jobs_Insert
> 'verbal' ,
> '4-24-2006',
> 0,
> 'FE' ,
> 'MEM' ,
> 'Johnson' ,
> '456' ,
> 'A300' ,
> '200' ,
> 'Started' ,
> ' ' ,
> ' ' ,
> ' ' ,
> 0 ,
> 131 ,
> 217 ,
> 189 ,
> 76 ,
>@ROnumber = @ret output
>
>print @ret
>-- shows 506008715
>I need to receive the @ret or @ROnumber
>
>RONumber is what I want to display in my interface.
>
>I am following this example from the MM help:
>
>Here is some sample code demonstrating how to retrieve output parameters from a command object returned from the ExecSprocScalar command:
>
>In C#:
>
>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;
>}
>
>I can't figure how to add all the params for input, as well as use the output for my own use.
>
>I was kind of waiting on Kevin to pop in, or someone else?? :)
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