Informix for .NET 的连接字符串

发布于 2024-07-14 16:38:02 字数 1333 浏览 4 评论 0原文

我们正在使用 Informix 数据库,并使用 ODBC 从 .NET 成功连接到它。 我们使用的连接字符串是;

DRIVER={IBM INFORMIX ODBC RIVER};
UID=username; PWD=password;
DATABASE=our_database;
HOST=devsrv01;
SERVER=devsrv01_tcp;
SERVICE=ids9tcp2;
PROTOCOL=onsoctcp;
CLIENT_LOCALE=en_US.CP1252;
DB_LOCALE=en_US.819;

我们希望从 ODBC 更改为使用 IBM 的 SDK 和库 在他们的网站上概述了

我们使用的代码是;

string ConnectionString = "Database=our_database; Server=172.22.0.0:1528; UID=username; Password=password; ";

try
{                               
    IfxConnection conn = new IfxConnection(ConnectionString);
    conn.Open();
}
catch (IfxException ex)
{}

conn.Open() 抛出异常;

错误 [08001] [IBM] SQL30081N 检测到通信错误。 使用的通信协议:“TCP/IP”。 使用的通信 API:“SOCKETS”。 检测到错误的位置:“172.22.0.0”。 通信函数检测到错误:“recv”。 协议特定错误代码:“”、“”、“0”。 SQLSTATE=08001

"啊哈!" 你说。 只需输入“PROTOCOL=onsoctcp;”即可,但这会使 IfxConnection(ConnectionString); 命令抛出 ArgumentException。 如果连接字符串包含任何无效的 = 设置,则会引发此异常。 如果我放入garbage=junk; 它抛出相同的 ArgumentException ,这让我认为它无法识别协议(或 PRO)字段。

(仅供参考)172.22.0.0 是 devsrv01 的 IP,并且不以 0.0.0 结尾。

We are using an Informix database, and are connecting to it from .NET sucessfully using ODBC. The connection string we are using is;

DRIVER={IBM INFORMIX ODBC RIVER};
UID=username; PWD=password;
DATABASE=our_database;
HOST=devsrv01;
SERVER=devsrv01_tcp;
SERVICE=ids9tcp2;
PROTOCOL=onsoctcp;
CLIENT_LOCALE=en_US.CP1252;
DB_LOCALE=en_US.819;

We want to change from ODBC and use IBM's SDK and libraries as outlined on their site.

The code we are using is;

string ConnectionString = "Database=our_database; Server=172.22.0.0:1528; UID=username; Password=password; ";

try
{                               
    IfxConnection conn = new IfxConnection(ConnectionString);
    conn.Open();
}
catch (IfxException ex)
{}

The conn.Open() throws the exception;

ERROR [08001] [IBM] SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "172.22.0.0". Communication function detecting the error: "recv". Protocol specific error code(s): "", "", "0". SQLSTATE=08001

"Ah ha!" you say. Just put in "PROTOCOL=onsoctcp;" But this makes the IfxConnection(ConnectionString); command throw an ArgumentException. If the connection string contains any invalid <field>=<value> setting it throws this exception. If I put in garbage=junk; in it throws the same ArgumentException which makes me think it doesn't recognise the Protocol (or PRO) field.

(FYI) 172.22.0.0 is the IP for devsrv01 and does not end 0.0.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

感情废物 2024-07-21 16:38:02

我最终发现答案是包括;

Persist Security Info=True;Authentication=Server;

别问我为什么。 我只是让它发挥作用。

为大家+1 - 感谢您的帮助。

I eventaully found out that the answer was to include;

Persist Security Info=True;Authentication=Server;

Don't ask me why. I just makes it work.

+1 for everyone - thanks for your help.

悲喜皆因你 2024-07-21 16:38:02

您检查过 http://www.connectionstrings.com/ 吗? 它可能会提供一些见解。

Did you check http://www.connectionstrings.com/ ? It might offer some insight.

靖瑶 2024-07-21 16:38:02

假设您想要使用 .NET、Informix CSDK(不是 DRDA)和 ADO.NET,最简单的连接方法是将数据库添加到 Visual Studio 的数据连接列表(查看 -> 服务器资源管理器,然后单击“连接到数据库”按钮,然后填写表格(假设您使用 CSDK 安装了 Visual Studio 扩展...))。

然后进入项目的属性,进入设置选项卡,添加一个类型为“(连接字符串)”的新设置,并输入值:

 Database=mydatabase;Password=mypassword;Server=myserver;User ID=myuser"

因此在 app.config 中,它看起来像这样:

 <add name="MyApplication.Properties.Settings.MyConnectionString"
  connectionString="Database=mydatabase;Password=mypassword;Server=myserver;User ID=myuser"
  providerName="IBM.Data.Informix" />

还要确保数据库和服务器已在主机文件 (C:\Windows\System32\drivers\etc\hosts) 中配置和/或使用位于开始菜单某处的 Informix 数据库连接工具“inetd32.exe”...

此外,如果您因此,您可以将服务器资源管理器窗口中的数据库中的表等拖到 Visual Studio 中打开的 XSD 文件上,以使其自动将连接字符串添加到配置中并设置所有内容以提供类型化数据集,并且它将处理为您提供 CRUD 层...(尽管您可能会收到一堆错误,因为 VS 由于某种原因无法使用最新的驱动程序提取 Informix 模式...)

无论如何,您可以使用连接字符串,例如:

IfxConnection myconnection = new IfxConnection(MyApplication.Properties.Settings.Default.MyConnectionString);

Assuming you want to use the .NET, the Informix CSDK (not the DRDA one) and ADO.NET the easiest way to get connected is to use add the database to Visual Studio's list of Data Connections (View -> Server Explorer, then click the "Connect to Database" button, then just fill in the form (This assumes you installed the Visual Studio Extensions with the CSDK...)).

Then go into the project's properties, go to the setting tab, add a new setting with a type of '(Connection String)' and for the value put:

 Database=mydatabase;Password=mypassword;Server=myserver;User ID=myuser"

So in the app.config it will look something like this:

 <add name="MyApplication.Properties.Settings.MyConnectionString"
  connectionString="Database=mydatabase;Password=mypassword;Server=myserver;User ID=myuser"
  providerName="IBM.Data.Informix" />

Also make sure the database and server has been configured in the hosts file (C:\Windows\System32\drivers\etc\hosts) and/or with the Informix Database Connection Tool 'inetd32.exe' located in the Start Menu somewhere...

Also if you so feel inclined you can drag tables and such from the database in the Server Explorer window onto a opened XSD file in Visual Studio to have it automaticlly add the connection string to the configuration and setup everything to give you a typed dataset and it will handled the CRUD layer for you... (Though you might get a bunch of errors because VS cannot pull the Informix schema using the latest drivers for some reason...)

Anyway, you can then use the connection string like:

IfxConnection myconnection = new IfxConnection(MyApplication.Properties.Settings.Default.MyConnectionString);
醉南桥 2024-07-21 16:38:02

IBM Informix .NET Povider 指南 4.10 手册使用Protocol或PRO而不是PROTOCOL。 关键字区分大小写吗? 符号表明可能是这样,但我对 .NET 的了解还不够确定。 使用 PROTOCOL 时出现的错误表明它可能区分大小写。

The IBM Informix .NET Povider Guide 4.10 manual uses Protocol or PRO rather than PROTOCOL. Are the keywords case-sensitive? The notation suggests it might be, but I don't know enough about .NET to be sure. And the error you get when you use PROTOCOL suggests that it might be case-sensitive.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文