日期:2014-05-17  浏览次数:20988 次

困恼小久的问题,高版本informix SDK连接数据库报错问题。
主要想使用高版本sdk中的IBM.Data.Informix.IfxBulkCopy。
高版本的sdk某些功能使用了db2的低层dll,网络上针对IDS高版本SDK报错搜索到的回复均为db2的解决方案,查找后并未找到问题所在。
引用IBM.DATA.informix.dll(2.81.0.0和3.0.0.2版本执行如下代码可以正常连接到数据库)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using IBM.Data.Informix;

namespace WindowsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            IfxConnection c = null;
            try
            {
                c = new IfxConnection("Server=ontest;Host=10.1.1.14;Service=8888;Protocol=onsoctcp;Database=testdb;UID=user;Password=xxx;CLIENT_LOCALE=zh_CN.GB18030-2000;DB_LOCALE=zh_CN.GB18030-2000;connection timeout=30;connection reset=False");
                c.Open();
                this.Text = c.Server + " " + c.ServerType + " " + c.ServerVersion;
                Clipboard.SetText(this.Text);
//返回ontest Informix 11.50.0000 FC6
            }
            finally
            {
                if (c != null && c.State != ConnectionState.Closed) c.Close();
                if (c != null) c.Dispose();
                c = null;
            }
        }
    }
}

引用IBM.DATA.informix.dll(9.0.0.2或者9.7.4.4版本无法连接上数据库),用如下代码无法连接上数据库
 //http://www.ibm.com/developerworks/forums/message.jspa?messageID=14628016 (参考此链接未能解决问题,在Setnet32中已经配置了服务器和客户端的编码集,)
            IfxConnectionStringBuilder cb = null;
            IfxConnection c = null;
            try
            {
                cb = new IfxConnection