【问题标题】:Connect to informix database windows form application连接到 informix 数据库 windows 窗体应用程序
【发布时间】:2014-09-10 17:16:59
【问题描述】:

我想弄清楚如何连接到 IBM informix 数据库。我一直在做一些研究,并发现了 5 年前的一些线程,但这些示例不起作用。

我已经安装了来自 IBM 的最新 SDK for informix。

我已将 IBM.Data.Informix.dll 包含在我的项目中的引用中。

我已包含使用 IBM.Data.Informix;

我只是添加一个按钮并单击测试连接。我总是得到这个调试错误 “SQL0035N 文件“C:\Users\Adam\documents\visual studio 2010\Projects\test\test\msg\en_US\db2nmp.xml”无法打开。”

此文件不存在,我在 Program Files (x86)\IBM Informix Client SDK 目录中的任何地方都看不到它。

我的点击代码是

    private void button1_Click(object sender, EventArgs e)
    {
        const string HOST = "192.168.OBFUSCATED";
        const string SERVICENUM = "1525"; //Port?
        const string SERVER = "serverOBFUSCATED";
        const string DATABASE = "dbOBFUSCATEDy";
        const string USER = "myusername";
        const string PASSWORD = "mypassword";

        string ConnectionString = "Host=" + HOST + "; " +
         "Service=" + SERVICENUM + "; " +
         "Server=" + SERVER + "; " +
         "Database=" + DATABASE + "; " +
         "User Id=" + USER + "; " +
         "Password=" + PASSWORD + "; ";

        IfxConnection conn = new IfxConnection();
        conn.ConnectionString = ConnectionString;
        try
        {
            conn.Open();
            MessageBox.Show("Made connection!");
        }
        catch (IfxException ex)
        {
            MessageBox.Show("Problem with connection attempt: " + ex.Message);
        }
    }

有人知道我做错了什么或当前连接到 informix 数据库的最佳方式吗?

提前致谢。

【问题讨论】:

    标签: visual-studio-2010 database-connection informix


    【解决方案1】:

    检查您的informix 版本。 您需要的是与您安装的 informix 数据库版本兼容的连接器。

    检查这个: http://www.ibm.com/developerworks/data/library/techarticle/dm-1007dsnetids/index.html

    【讨论】:

    • 这与 conn.ConnectionString = ConnectionString; 上发生的错误有什么关系。我实际上并没有安装它,只是为我正在做的事情做准备。我将在我的服务器上安装informix,然后再试一次。但我非常怀疑这是导致它出错的原因,而不仅仅是抓住问题。我需要从某个地方复制那个 msg\en_US\db2nmp.xml 吗?
    【解决方案2】:

    我遇到了同样的错误,请尝试使用以下格式形成您的字符串:

    string ConnectionString = "Server=" + HOST + ":" + SERVICENUM + "; " +
         "Database=" + SERVER + "\" + DATABASE + "; " +
         "User Id=" + USER + "; " +
         "Password=" + PASSWORD + "; ";
    

    使用示例中的值,结果应该是:

    "Server=192.168.OBFUSCATED:1525;Database=serverOBFUSCATED\dbOBFUSCATEDy;User ID=myusername;Password=mypassword;"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多