Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

FIX: Error message when you run an SQL statement by using OLE DB Provider for DB2: "SQLSTATE 22007, SQLCODE -181"


View products that this article applies to.

Symptoms

Consider the following scenario. You run an SQL statement by using Microsoft OLE DB Provider for DB2. The SQL statement passes a Microsoft SQL Server datetime parameter to an IBM DB2 database column. The IBM DB2 database column uses the IBM DB2 DATE data type. In this scenario, you may receive the following error message:
SQLSTATE: 22007, SQLCODE: -181
For example, the following SQL statement passes a SQL Server datetime parameter to an IBM DB2 database column.
declare @var1 datetime
set @var1 = '2006-09-27 00:00:00.000'
SELECT COL1, COL2, COL3
FROM IBMDB2.TESTDATA.USER1.TABLE1
WHERE COL2 = @var1
In this example, this problem occurs if the COL2 column uses the IBM DB2 DATE data type.

↑ Back to the top


Cause

At runtime, OLE DB Provider for DB2 does not know the correct IBM DB2 data type for the IBM DB2 database column to which the SQL Server datetime parameter is passed. Therefore, OLE DB Provider for DB2 includes the date information and the time information in the value that OLE DB Provider for DB2 passes to the IBM DB2 database. The time information is not valid for the IBM DB2 DATE data type. Therefore, you receive the error message that is mentioned in the "Symptoms" section.

↑ Back to the top


Resolution

Microsoft Host Integration Server 2006

To resolve this problem, obtain the latest service pack for Host Integration Server 2006. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
979497 How to obtain the latest Host Integration Server 2006 service pack

Microsoft Host Integration Server 2004

A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.

If the hotfix is available for download, there is a "Hotfix download available" section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the hotfix.

Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft Web site: Note The "Hotfix download available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.

File information

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.
File nameFile versionFile sizeDateTimePlatformSP requirement
Db2oledb.dll6.0.2048.0488,96003-Nov-200617:31x86SP1
Db2oledb.hNot Applicable24,57903-Nov-200617:36Not ApplicableSP1
Ddmstr.dll6.0.2048.044,03203-Nov-200617:31x86SP1
Drdaresync.exe6.0.2048.0337,40803-Nov-200617:32x86SP1
Microsoft.hostintegration.dataaccesslibrary.dll6.0.2048.086,01603-Nov-200617:31x86SP1
Microsoft.hostintegration.dataaccesstool.exe6.0.2048.02,703,36003-Nov-200617:32x86SP1
Microsoft.hostintegration.msdb2client.dll6.0.2048.0114,68803-Nov-200617:31x86SP1
Mseidb2c.dll6.0.2048.071,68003-Nov-200617:31x86SP1
Mseidb2d.dll6.0.2048.0435,20003-Nov-200617:31x86SP1
Mseidrda.dll6.0.2048.0695,80803-Nov-200617:32x86SP1
Note Because of file dependencies, the most recent hotfix that contains these files may also contain additional files.

Microsoft OLE DB Provider for DB2 version 1.0

A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing this specific problem. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.

If the hotfix is available for download, there is a "Hotfix download available" section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the hotfix.

Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft Web site: Note The "Hotfix download available" form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.

File information

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.
32-bit (x86) version
File nameFile versionFile sizeDateTimePlatformSP requirement
Db2oledb.dll6.0.2048.0488,96003-Nov-200617:31x86SP1
Db2oledb.hNot Applicable24,57903-Nov-200617:36Not ApplicableSP1
Ddmstr.dll6.0.2048.044,03203-Nov-200617:31x86SP1
Drdaresync.exe6.0.2048.0337,40803-Nov-200617:32x86SP1
Microsoft.hostintegration.dataaccesslibrary.dll6.0.2048.086,01603-Nov-200617:31x86SP1
Microsoft.hostintegration.dataaccesstool.exe6.0.2048.02,703,36003-Nov-200617:32x86SP1
Microsoft.hostintegration.msdb2client.dll6.0.2048.0114,68803-Nov-200617:31x86SP1
Mseidb2c.dll6.0.2048.071,68003-Nov-200617:31x86SP1
Mseidb2d.dll6.0.2048.0435,20003-Nov-200617:31x86SP1
Mseidrda.dll6.0.2048.0695,80803-Nov-200617:32x86SP1
64-bit (x64) version
File nameFile versionFile sizeDateTimePlatformService branch
Db2oledb.dll7.0.2535.0758,54407-Nov-200612:34x64Not Applicable
Microsoft.hostintegration.dataaccesslibrary.dll7.0.2535.02,550,61607-Nov-200612:34x64Not Applicable
Microsoft.hostintegration.dataaccesstool.exe7.0.2535.0613,20007-Nov-200612:34x64Not Applicable
Mseidrda.dll7.0.2535.01,355,53607-Nov-200612:34x64Not Applicable
Snanls.dll7.0.2535.0128,77607-Nov-200612:34x64Not Applicable
Db2oledb.dll7.0.2535.0516,88007-Nov-200612:34x86SYSWOW
Mseidrda.dll7.0.2535.0781,07207-Nov-200612:34x86SYSWOW
Snanls.dll7.0.2535.0105,22407-Nov-200612:34x86SYSWOW
Note Because of file dependencies, the most recent hotfix that contains these files may also contain additional files.

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

↑ Back to the top


More information

This hotfix adds support for a new connection string property. By using the new connection string property, you can pass a SQL Server datetime parameter to an IBM DB2 database as the IBM DB2 DATE data type. OLE DB Provider for DB2 deletes the time information in the value of the SQL Server datetime parameter. Therefore, OLE DB Provider for DB2 passes only the date information to the IBM DB2 database.

The new connection string property has the following definition:
DateTime As Date=Value
In this connection string property, you can define Value as TRUE or as FALSE. If you add the DateTime As Date=TRUE statement to the connection string, OLE DB Provider for DB2 converts the SQL Server datetime parameter to the IBM DB2 DATE data type. Then, OLE DB Provider for DB2 passes the value to the IBM DB2 database.

If you add the DateTime As Date=FALSE statement to the connection string, OLE DB Provider for DB2 passes the SQL Server datetime parameter to the IBM DB2 database as you specify in the SQL statement. In this case, OLE DB Provider for DB2 passes the date information and the time information to the IBM DB2 database.

Note This behavior is the default behavior if you do not add the DateTime As Date property to the connection string.

The following connection string example shows how to use the DateTime As Date property.
; Everything after this line is an OLE DB initialization string.
Provider=DB2OLEDB;Password=<Password>;Persist Security Info=True;User ID=<Username>;Initial Catalog=S105FRDM;Defer Prepare=False;Derive Parameters=False;Network Transport Library=TCP;Host CCSID=37;PC Code Page=1252;Network Address=<Address>;Network Port=446;Package Collection=DB2USER;Default Schema=DB2USER;Default Qualifier=DB2USER;DBMS Platform=DB2/AS400;Process Binary as Character=False;Connection Pooling=True;Units of Work=RUW;DateTime As Date=TRUE
Important After you apply this hotfix and add the DateTime As Date=TRUE statement to the connection string, you may receive the following error message:
SQLSTATE: 22007, SQLCODE: -180
This problem occurs if the IBM DB2 database column uses the IBM DB2 TIMESTAMP data type. This problem occurs because the IBM DB2 database expects to receive the date information and the time information when a query is passed to an IBM DB2 database column that uses the IBM DB2 TIMESTAMP data type. The DateTime As Date=TRUE statement causes OLE DB Provider for DB2 to delete the time information in the value of the SQL Server datetime parameter. Therefore, the data is not valid when the query is passed to the IBM DB2 database column that uses the IBM DB2 TIMESTAMP data type.

If you must query an IBM DB2 table that uses the IBM DB2 DATE data type and the IBM DB2 TIMESTAMP data type, you may have to use multiple connection strings that are configured to use the correct properties. Then, you can successfully query the various IBM DB2 data types.

For more information, click the following article number to view the article in the Microsoft Knowledge Base:
824684 Description of the standard terminology that is used to describe Microsoft software updates
The third-party products that this article discusses are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, about the performance or reliability of these products.

↑ Back to the top


Keywords: kbdb2oledb, kbhis2004, kbfix, kbbug, kbHotfixServer, kbqfe, kbautohotfix, KB924599

↑ Back to the top

Article Info
Article ID : 924599
Revision : 3
Created on : 10/9/2011
Published on : 10/9/2011
Exists online : False
Views : 411