君沐慈 2014-10-06 03:01
浏览 1105

windowCE C#开发的应用程序下连接informix

各位高手,最近CE下的项目需要从sqlserver的数据库移植到informix的数据库。
环境:linux操作系统用开源版本centos6.5
informix免费版:IBM Informix Dynamic Server Version 11.70.FC8IE
VS2008,程序运行:CE5与CE6,终端型号:MC3090(ce5)与MC3190(ce6)

我按照ado.net的连接试了下,下载了IBM.Data.Informix.dll 版本:3.0.0.2 添加引用

string s = "Database=dbbos;Host=10.1.31.101;"
+"Server=xxx;Service=xxx;Protocol=onsoctcp;"+
"UID=informix;Password=xxxx;"+
"CLIENT_LOCALE=zh_CN.GB18030-2000;"+
"DB_LOCALE=zh_CN.GB18030-2000;";

        IfxConnection c = null;
        try
        {
            c = new IfxConnection(s);
            c.Open();
            this.Text = c.Server + " " + c.ServerType + " " + c.ServerVersion;
        string sql="select * from goods where barcodeid='6921168509256'";
         IfxCommand ic = new IfxCommand(sql,c);

           IfxDataReader fd= ic.ExecuteReader();
            if(fd.Read())
            {
                MessageBox.Show(fd["barcodeid"].ToString());
                MessageBox.Show(fd["goodsname"].ToString());
            }
            Clipboard.SetText(this.Text);

        }catch(Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
        finally
        {
            if (c != null && c.State != ConnectionState.Closed) c.Close();
            if (c != null) c.Dispose();
            c = null;
        }

然后成功连接了。不过当我移植之后,编译不通过。说我没引用错误  

145 类型“System.Data.Common.DbConnection”在未被引用的程序集中定义。必须添加对程序集“System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”的引用。

然后我尝试去ado.net的system.data.dll文件拷贝出来,然后引用,却无法引用。
请各位大神告知下如何能连接成功?如果用odbc是否在服务器端下需要配置dns?有详细的方式提供最好了,谢谢!!

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 overleaf中论文编辑,报错`pages' is a missing field, not a string, for entry 4
    • ¥15 vhdl+MODELSIM
    • ¥20 simulink中怎么使用solve函数?
    • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
    • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
    • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
    • ¥15 知识蒸馏实战博客问题
    • ¥15 用PLC设计纸袋糊底机送料系统
    • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
    • ¥15 用C语言输入方程怎么