pythonian29033
pythonian29033

Reputation: 5207

How to connect to an Informix Database from an ASP.NET script?

I've never coded in ASP.NET, but I've been a web (PHP) developer for almost 3years now, Problem is I've never coded in anything .NET after I completed my studies and I've never worked with IIS and MS Servers either.

I need to create a connection from an ASP.NET (VB) script to an Informix database. google took me to this; IBM Informix connection example but I haven't a clue how to add these drivers to IIS, the IBM Informix Client SDK is installed on the server, but when I open the dialogs in IIS to add them as Handlers, I'm prompted for things I don't know the meaning of, I haven't found anything that says tutorial that is of any help and nor have I found anything on stack overflow.

I feel like an African stuck in China, what the hell do I do first and where do I go?

Upvotes: 2

Views: 5133

Answers (3)

robnardo
robnardo

Reputation: 931

I had similar issues when trying to connect to an Informix DB from ASP.NET Console Application, but eventually found a way to connect! Here is the connection string i used that did the trick:

Database=db_cra;Host=192.168.160.207;Server=sipccx1_uccx;Service=1504;Protocol=onsoctcp;UID=MyUserId;Password=MyPassWord;DB_LOCALE=EN_US.UTF8;CLIENT_LOCALE=EN_US.UTF8;

Notes: The DB_LOCALE and CLIENT_LOCALE were the missing puzzle pieces for me. Also, "Service" means "Port" and "Server" is Informix instance name - defined in the database configuration (see: Finding Informix DB Server )

I downloaded and installed the Informix Client SDK provided by IBM and found that it comes with sample code (for both C# and VB). The path to the samples are C:\Program Files\IBM Informix Client SDK\demo\dotnetdemo\quickstart\cs

Add your connection string to the conninfo.xml file and run the file named helloworldconnect.cs as a console app to test connection. Your results will spit out into a file named "log.txt" (found in the bin/Debug folder).

BTW - I downloaded the 64 bit version of the "IBM Informix Client SDK". Trying to run it gave me "BadImageFormatException" so i had to switch my Platform Target to x64.

The SDK readme docs say it is IBM Informix .NET Provider Version 4.10.FC5 released on March 26, 2015. This link should give you a list of Windows 64 bit drivers (you will need to create an IBM account to download). On this page you can change the filter settings (top of page) to get other operating systems.

Whew.. now onto pulling data!

One more thing.. this book "IBM Informix Developer's Handbook" (https://play.google.com/books/reader?id=eprEAgAAQBAJ ) is a great resource and its free!

Upvotes: 0

pythonian29033
pythonian29033

Reputation: 5207

Okay, so as it turns out, I didn't find anything solid, so I went to find help in a clients office from an experienced .NET developer.

I was told to create a DSN on the server machine using ODBC, in the steps explained here

after that I referred to the DSN connection in the connection string, like this;

DSN=myDsn;Uid=myUsername;Pwd=p%W$d;

And I had to add impersonation to my asp.net scripts, as is done here using the same user I was logged in as when creating the DSN connections in ODBC

Upvotes: 1

I have used ODBC in the past to connect to Informix, like this. If you have an Informix DBA, he will provide the values for host, server, and service. host is the name of the host machine where the database server resides. service is the service name in the services file but it actually maps to the port Informix listens. Server is the actual server.

string connectionString = "Driver={INFORMIX};host=myhost;server=myserver;service=23300;protocol=onsoctcp;database=dbase;uid=user;pwd=pass;client_locale=en_US.CP1252;db_locale=en_US.8859-1;"

OdbcConnection conn = new OdbcConnection(connectionString);
conn.Open();

For more connection string samples, see here.

To test, you can create an ODBC data source and test the connection without writing any code.

Upvotes: 2

Related Questions