从代码更改/创建 ODBC 连接
我正在通过 ODBC 连接从 C# ASP .Net 4.0 使用 Informix DB。该数据库确实经常更改,因此我从 sysmaster 表中读取了安装的数据库。
根据我的用户所做的选择,我需要设置与所选数据库的 ODBC 连接,或更改当前连接以从 systmaster 数据库更改为所选数据库。
有人知道如何做到这一点吗?我怀疑必须可以设置临时 ODBC 连接。另外,在 Visual Studio 中,在 ODBC 连接的属性下,我确实有一个如下所示的连接字符串:
Dsn=Informix;uid=xxxxx;database=sysmaster;host=10.10.10.10;srvr=testdb1;serv=3000;pro=onsoctcp;cloc=en_US.819;dloc=en_US.819;vmb=0;curb=0;scur=0;icur=0;oac=1;optofc=0;rkc=0;odtyp=0;ddfp=0;dnl=0;rcwc=0
我四处寻找无需 ODBC 即可直接连接到 informix 的库,但现在成功了。
谢谢, 斯特凡
I'm working against a Informix DB from C# ASP .Net 4.0 via an ODBC connection. This database does change frequently so I read out what DBs that are installed from the sysmaster table.
Depending on choice my user makes I need to setup a ODBC connection to the choosen DB or change the current connection to change from the systmaster DB to the one choosen.
Anyone got any idea how to do this? I suspect it must be possible to setup a temporary ODBC connection. Also in Visual Studio under the properties for my ODBC connection I do have a connection string looking like this:
Dsn=Informix;uid=xxxxx;database=sysmaster;host=10.10.10.10;srvr=testdb1;serv=3000;pro=onsoctcp;cloc=en_US.819;dloc=en_US.819;vmb=0;curb=0;scur=0;icur=0;oac=1;optofc=0;rkc=0;odtyp=0;ddfp=0;dnl=0;rcwc=0
I have looked around for a library to connect directly without the ODBC to informix but with now success.
Thanks,
Stefan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经制定了一个非常好的工作解决方案。我没有意识到 .NET 完全支持从代码隐藏中执行此操作,而无需实际修改 ODBC 设置。
我想您必须在尝试后面的代码之前设置一个有效的 ODBC 连接,以确保驱动程序可以正常定位或至少查看可用的 ODBC 驱动程序列表。
I have worked out a working solution that is quite nice. I did not realise .NET had full support to do this from code behind without actually modifying the ODBC settings.
I guess you have to setup a working ODBC connection one before trying the code behind to just be sure the Driver can be located ok or at least look in the list of available ODBC drivers.
我想您可以直接修改注册表,但您也可以调用 odbcconf.exe,这是一个标准的 Windows 实用程序。 是一个 MSDN 链接
这 在研究如何操作 ODBC 连接时,我做了如下操作来添加连接:
当然,您可以用自己的参数替换
?
。I suppose you could mess with the registry directly, but you could also call
odbcconf.exe
, which is a standard Windows utility. Here's an MSDN linkBack when I was looking into how to manipulate ODBC connections, I did something like the following to add a connection:
Of course, you'd replace the
?
with your own parameters.