开发者

Cannot connect to Informix from ASP.NET application

I've installed the trial version of IBM Informix Dynamic Server 11.50 on my开发者_JS百科 development laptop, for use with an ASP.NET 2.0 app I'm writing. I have created a couple databases and filled them with sample data but I cannot connect. This is the relevant section of code:

Dim facStr As String = System.Configuration.ConfigurationManager.ConnectionStrings("fact").ConnectionString  
conn.ConnectionString = facStr
Try
    conn.Open()
Catch ex As Exception

The exception is:

[Informix .NET provider][Informix]Server ol_srv_custom is not listed as a dbserver name in sqlhosts.

The full path to the sqlhosts file is:

C:\Archivos de programa\IBM\Informix\Client-SDK\etc\sqlhosts

Informix's environment variables:

INFORMIXSQLHOSTS=C:\Archivos de programa\IBM\Informix\Client-SDK\etc\sqlhosts

Contents of sqlhosts file:

ol_srv_custom olsoctcp *nb-desarrollo svc_custom

Connect string:

**Host=*nb-desarrollo; Service=svc_custom; Server=ol_srv_custom; Database=fact; User Id=informix; password=**********

Any ideas?


ODBC doesn't work either. When I try to create the DSN the driver user interface asks me to select a "Server Name" from a combobox, but it's empty. In fact, the only way I have to connect to this Informix installation is using the console utility dbaccess, that's how I created the test databases and INSERTed the sample data. I'm not sure if this question still belongs in SO, maybe ServerFault might be more appropiate place to ask but I don't know how to move it.


I would also suggest you to create ODBC connection and test it. There is info how to do it with setnet32 (for older version): http://www.synametrics.com/ifmxODBC.htm


Documentation in internet and the error message are misleading. I had the same error and meanwhile I found out how to solve it.

When you install the Informix Client SDK for Windows and use the ODBC driver for Informix (with or without .NET) you must pass the following parameters:

  1. Host
  2. Server
  3. Service or Port
  4. Protocol
  5. User ID
  6. Password

All these parameters are mandatory. The database is optional.

In your connection string the protocol is missing. In the case that any parameter is missing the OBDC driver searches the server in the registry under

32 bit driver: HKLM\Software\Wow6432Node\Informix\SQLHOSTS\Servername

64 bit driver: HKLM\Software\Informix\SQLHOSTS\Servername

If the server is not listed there you get the error "Server XYZ is not listed as a dbserver name in sqlhosts."

Please note that only Linux uses an sqlhosts file. On Windows the same data is stored in the registry instead.

You do NOT need to create a sqlhosts file although the error message and the documentation and several webpages make you think that.

You do NOT need to use the IBM tool SetNet32 to generate entries for your server.

You just have to pass ALL mandatory parameters to the ODBC driver and the error is gone.

It is really a pitty that IBM is not able to give a more intelligent error message.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜