查找Informix Db Locale

问题描述 投票:-1回答:1

我正在下面的代码片段,我尝试连接到IBM的Informix数据库。

  public void MakeConnection()
        {
            string ConnectionString = "Database=databasename;Host=ipaddress;Server=servername;Service=port;Protocol = olsoctcp; UID = userid; Password = password;";
            IfxConnection conn = new IfxConnection();
            conn.ConnectionString = ConnectionString;
            try
            {
                conn.Open();
            }
            catch (IfxException ex)
            {
                Console.WriteLine(ex.ToString());
            }    
            Console.ReadLine();
        }

打开连接时出现以下错误。

错误[HY000] [Informix .NET提供程序] [Informix]数据库区域设置信息不匹配。

当我尝试使用windows ODBC Data sources应用程序进行连接时,通过在用户DSN下创建新的用户数据源并在Informix ODBC driver setup的每个部分下提供所有必要的值,我能够成功连接。

据我所知,客户端应用程序和数据库的Database Locale值应该相同,以便正确执行查询,并且我尝试使用en_US.57372 and en_US.UTF8数据库语言环境,同时在用户DSN中进行配置,效果非常好。我在这里张贴了一张图片,以便更好地理解。

ODBC Driver Setup for Informix and connectivity test

感谢是否有人可以帮助我知道在哪里可以找到在Informix数据库中配置的数据库区域设置,并且还详细说明了导致此错误的原因。

c# odbc informix
1个回答
0
投票

最后能够从测试应用程序连接到数据库!好的,我们走了,

第1步:首先我们需要找到数据库允许我们使用的数据库区域设置?所以按照他在评论部分提到的@Luis Marques的方式,发现Database Locale使用的是en_US.57372,也支持en_US.UTF8

第2步:默认情况下,连接对象的client locale and database locale属性值将是安装Informix ODBC driver时设置的默认值。

稍微修改了我的测试应用程序代码,如下所示,

   public void MakeConnection()
        {
            string ConnectionString = "Database=databasename;Host=ipaddress;Server=servername;Service=port;Protocol = olsoctcp; UID = userid; Password = password;";
            IfxConnection conn = new IfxConnection();
            conn.ConnectionString = ConnectionString;
            conn.ClientLocale = "en_US.UTF8";
            conn.DatabaseLocale = "en_US.UTF8";
            try
            {
                conn.Open();
            }
            catch (IfxException ex)
            {
                Console.WriteLine(ex.ToString());
            }    
            Console.ReadLine();
        }

因此,手动为连接对象分配client and database locale值与我们在步骤1中获得的值解决了问题。

© www.soinside.com 2019 - 2024. All rights reserved.