[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

Exception when executing a stored procedure

Matthias Kientz

9/3/2002 5:02:00 PM

First some facts about I want to do:

Declaration of SP:
CREATE PROCEDURE dbo.sp_WnGetMasterIds
-- input params
@strTableName varchar(50),
@intNbIds int,
-- output params
@strOut varchar(8000) OUT -- 8000 is the maximum for varchar
AS ...

To execute the SP, I create a command an add the parameters to the
OdbcParameterCollection.
I've set then CommandText as {? = call sp_WnGetMasterIds (?,?,?)} and tried
to execute this with ExecuteNonQuery() and got the following Exception:

Microsoft.Data.Odbc.OdbcException: ERROR - no error information available
at Microsoft.Data.Odbc.OdbcConnection.HandleError(IntPtr hHandle,
SQL_HANDLE hType, RETCODE retcode)
at Microsoft.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior
behavior, String method)
at Microsoft.Data.Odbc.OdbcCommand.ExecuteNonQuery()
...

The last parameter (@strOut) is of OdbcType NVarChar, Size = 8000, Value is
an empty string
I've done some tests with differnt sizes and I found out, that all works OK
if I set the the size of this parameter less than 2000.

This seems to be the size of an internal parameter cache.
Any ideas (beside using Varchar(1999) in stored procedure)?


Thanks for help
Matthias Kientz



2 Answers

laled

9/4/2002 12:52:00 AM

0

Make sure you explicitly specify the size of the output
parameter in your parameter collection.

laled

This posting is provided "AS IS" with no warranties, and
confers no rights.

>-----Original Message-----
>First some facts about I want to do:
>
>Declaration of SP:
>CREATE PROCEDURE dbo.sp_WnGetMasterIds
>-- input params
>@strTableName varchar(50),
>@intNbIds int,
>-- output params
>@strOut varchar(8000) OUT -- 8000 is the maximum for
varchar
>AS ...
>
>To execute the SP, I create a command an add the
parameters to the
>OdbcParameterCollection.
>I've set then CommandText as {? = call sp_WnGetMasterIds
(?,?,?)} and tried
>to execute this with ExecuteNonQuery() and got the
following Exception:
>
>Microsoft.Data.Odbc.OdbcException: ERROR - no error
information available
> at Microsoft.Data.Odbc.OdbcConnection.HandleError
(IntPtr hHandle,
>SQL_HANDLE hType, RETCODE retcode)
> at Microsoft.Data.Odbc.OdbcCommand.ExecuteReaderObject
(CommandBehavior
>behavior, String method)
> at Microsoft.Data.Odbc.OdbcCommand.ExecuteNonQuery()
> ...
>
>The last parameter (@strOut) is of OdbcType NVarChar,
Size = 8000, Value is
>an empty string
>I've done some tests with differnt sizes and I found
out, that all works OK
>if I set the the size of this parameter less than 2000.
>
>This seems to be the size of an internal parameter cache.
>Any ideas (beside using Varchar(1999) in stored
procedure)?
>
>
>Thanks for help
>Matthias Kientz
>
>
>
>.
>

Matthias Kientz

9/5/2002 1:12:00 PM

0

I specified the Size, DbType, Value, Name and Direction of the output
parameter in the parameter collection.

This is the reason I was surprised at getting an exception if I set the size
more than 1999 (the output parameter in the stored procedure is still
declared as VARCHAR(8000)).
OK, I've seen the ODBC Datatype(DbType.String) was mapped to NVarChar. I
changed this to Varchar (DbType.AnsiString) and the new limit is at 4000. I
think this should be 8000. Or not?
If I set the size at 4000 or more I'll get an exception.

Or is ODBC.NET limited to handle only VARCHAR(less than 4000)?

Thanks


"laled" <laled@nospam.microsoft.com> schrieb im Newsbeitrag
news:11db601c253a5$05b989f0$39ef2ecf@TKMSFTNGXA08...
> Make sure you explicitly specify the size of the output
> parameter in your parameter collection.
>
> laled
>
> This posting is provided "AS IS" with no warranties, and
> confers no rights.
>
> >-----Original Message-----
> >First some facts about I want to do:
> >
> >Declaration of SP:
> >CREATE PROCEDURE dbo.sp_WnGetMasterIds
> >-- input params
> >@strTableName varchar(50),
> >@intNbIds int,
> >-- output params
> >@strOut varchar(8000) OUT -- 8000 is the maximum for
> varchar
> >AS ...
> >
> >To execute the SP, I create a command an add the
> parameters to the
> >OdbcParameterCollection.
> >I've set then CommandText as {? = call sp_WnGetMasterIds
> (?,?,?)} and tried
> >to execute this with ExecuteNonQuery() and got the
> following Exception:
> >
> >Microsoft.Data.Odbc.OdbcException: ERROR - no error
> information available
> > at Microsoft.Data.Odbc.OdbcConnection.HandleError
> (IntPtr hHandle,
> >SQL_HANDLE hType, RETCODE retcode)
> > at Microsoft.Data.Odbc.OdbcCommand.ExecuteReaderObject
> (CommandBehavior
> >behavior, String method)
> > at Microsoft.Data.Odbc.OdbcCommand.ExecuteNonQuery()
> > ...
> >
> >The last parameter (@strOut) is of OdbcType NVarChar,
> Size = 8000, Value is
> >an empty string
> >I've done some tests with differnt sizes and I found
> out, that all works OK
> >if I set the the size of this parameter less than 2000.
> >
> >This seems to be the size of an internal parameter cache.
> >Any ideas (beside using Varchar(1999) in stored
> procedure)?
> >
> >
> >Thanks for help
> >Matthias Kientz
> >
> >
> >
> >.
> >