Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Calling a Stored Procedure with Output Parameter
Message
De
25/06/2010 16:37:33
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Calling a Stored Procedure with Output Parameter
Divers
Thread ID:
01470620
Message ID:
01470620
Vues:
98
Hi,

I am trying to follow the example in the help file to get a value out of a stored procedure.

The stored procedure returns a string in its output parameter:
CREATE PROCEDURE TestNewNumber 

 @NewNumber varchar(10)
OUTPUT
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	SET @NewNumber = '00000'
END


 RETURN @NewNumber
The C# code I am using is this:
                // Create the parameter and set the direction
                IDbDataParameter param1 = this.CreateParameter("@newNumber", 0);
                param1.Direction = ParameterDirection.Output;

                IDbCommand cmd;
                this.ExecSprocScalar("TestNewNumber", out cmd, param1);

                // Retrieve the value from the command object
                IDbDataParameter param = (IDbDataParameter)cmd.Parameters["@newNumber"];
                string newNumber = (string)param.Value;
The problem is that param.Value is returning an integer (0 in this case) rather than the expected string '00000'.

What am I doing wrong?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform