Groups | Blog | Home
all groups > dotnet odbc.net > february 2004 >

dotnet odbc.net : "Connection is dead" on ODBC insert of decimal into DB2


jdatbp NO[at]SPAM yahoo.co.uk
2/17/2004 12:08:03 PM
I am having problems inserting Decimal values into a DB2 database via
a .NET/C# application which is using an OdbcDataAdapter. Other field
types such as VarChar, Int, Date, etc work ok, and I can insert
literal values into a decimal field, but any attempt to insert a
decimal field via an OdbcParameter causes a
System.InvalidOperationException ("The connection is dead") to be
thrown by the DbDataAdapter.Update method.

The ODBC driver is IBM's DB2 Connect Personal Edition, Version 5
(installed as part of IBM DB2 Universal Database for Windows NT,
Version 5).

A typical failing OdbcParameter follows:

this.odbcInsertCommand1.Parameters.Add(
new System.Data.Odbc.OdbcParameter(
"API_GRAVITY",
System.Data.Odbc.OdbcType.Decimal,
0,
System.Data.ParameterDirection.Input,
false,
((System.Byte)(4)),
((System.Byte)(1)),
"API_GRAVITY",
System.Data.DataRowVersion.Current, null));

The database field is defined as DECIMAL 4 in the DB2 database.

Has anyone come across this before? Any suggestions for fixes or
workarounds?

Many thanks in advance,

John

Posted to: microsoft.public.dotnet.framework.odbcnet +
Sam
2/25/2004 7:26:07 PM
John

I have a C#.NET application which is using ODBC to connect to a DB2 database on AS/400 system. I am able to pass decimals with out any problem. The difference seems to be that on DB2 the database field is defined as a NUMBER(10,0)

I am doing the following

odbcparam = new OdbcParameter(OdbcType.Decimal
odbcparam.value = decimalfiel
Parameters.Add(odbcparam

AddThis Social Bookmark Button