Re: Return value of a stored procedure using C#.
- From: Gerard <Gerard@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 10 Jun 2005 23:54:02 -0700
I added this in my and nothing changed. (see below)
I can not get the returned value.
Regards,
Gerard
"Uwa Agbonile [MSFT]" wrote:
> I believe you need to set the command type to StoredProcedure like
> dbCmd.CommandType = CommandType.StoredProcedure;
>
> Also, you might want to post this to the ODBC .NET newsgroup next time.
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
> Use of included script samples are subject to the terms specified at
> http://www.microsoft.com/info/cpyright.htm
>
> Regards,
> Uwa Agbonile[MSFT]
>
> "Gerard" <Gerard@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:45F10934-0A0B-4879-94BE-662B95798E0A@xxxxxxxxxxxxxxxx
> > Hi all,
> > I tried to get the return value of a stored procedure in Ado.Net C#
> program
> > without sucess.
> > Have somebody any idea ?
> > Regards,
> > Gerard
> >
> > Here is my code:
> >
> > using System.Data.Odbc;
> > //...
> > OdbcConnection dbConn = null;
> > try
> > {
> > dbConn = new OdbcConnection ( "DRIVER={SQL
> >
> Server};SERVER=XXXX;DATABASE=tempdb;UID=XXXX;PWD=YYYY;WorkstationID=XXXX;App
> licationName=TEST;" );
> > OdbcCommand dbCmd = dbConn.CreateCommand();
dbCmd.CommandType = System.Data.CommandType.StoredProcedure;
> > dbCmd.Parameters.Add("@RETVAL",OdbcType.Int).Direction =
> > System.Data.ParameterDirection.ReturnValue;
> > dbCmd.CommandText = "pAdd 2,8";
> > dbConn.Open();
> > dbCmd.ExecuteNonQuery();
> > System.Console.WriteLine( "Return: " +
> > dbCmd.Parameters[0].Value.ToString());
> > System.Console.WriteLine( "Return: " + dbCmd.Parameters[0].ToString());
> //
> > --> @RETVAL
> > System.Console.WriteLine( "Return: " + dbCmd.Parameters[0].Value);
> > System.Console.WriteLine( "Return: " +
> dbCmd.Parameters["@RETVAL"].Value);
> > }
> > catch(OdbcException exp)
> > {
> > System.Console.WriteLine("OdbcException exception
> catched\r\n"+exp.Message);
> > }
> > catch(Exception exp)
> > {
> > System.Console.WriteLine("Exception catched\r\n"+exp.Message);
> > }
> > finally
> > {
> >
> > if ( dbConn != null )
> > {
> > dbConn.Close();
> > dbConn = null;
> > }
> > }
> >
>
>
>
.
- References:
- Rvalue of a stored procedure using C#
- From: Gerard
- Re: Rvalue of a stored procedure using C#
- From: Uwa Agbonile [MSFT]
- Rvalue of a stored procedure using C#
- Prev by Date: Re: Rvalue of a stored procedure using C#
- Next by Date: DB2/400 ODBC Connectivity - HELP
- Previous by thread: Re: Rvalue of a stored procedure using C#
- Next by thread: DB2/400 ODBC Connectivity - HELP
- Index(es):
Relevant Pages
|
Loading