Use C # To connect to Informix in a 64-bit Operating System

Source: Internet
Author: User
Tags dsn informix informix odbc driver

Test environment: windows2008 + sql2008r2 + Linux Virtual Machine + informix9 database + IBM Informix-client SDK 3.70.fc4

Connection steps:

1. Enable Linux virtual machine, enable network configuration, and start Informix Database

2. Install the Informix Database client tool IBM Informix-client SDK 3.70.fc4 in windows. configure the following two configurations related to your INFORMIX database.

1. Open the c: \ windows \ system32 \ drivers \ etc \ hosts file in notepad and add

127.0.0.1 localhost
Informix_server_ip informix_server_name

Informix_server_ip is the IP address of the Linux server, for example, 192.168.1.100; informix_server_name is the name of the Linux server.

 

2. Open the c: \ windows \ system32 \ drivers \ etc \ hosts file in notepad and add

Informix_service_name informix_server_port/tcp # remote Linux INFORMIX Data Server

Here, informix_service_name is the service name of the Linux server, such as sqlinformix format; informix_server_port is the Informix Database Port Number of the Linux server, such as 8000.

 

3. Click Start> RUN> enter c: \ windows \ syswow64 \ odbcad32.exe to open the 64-bit ODBC data source Manager.

4. Add custom configurations to the Informix Database

1. Click the Add button in the user DSN form to create a new data source form. In the driver list, select "IBM Informix ODBC driver". Click "finish. Open the "IBM Informix ODBC driver setup" interface.

2. In the general form on the "IBM Informix ODBC driver setup" interface, enter the custom DSN name, for example, "testinformixdsn ".

3. On the "IBM Informix ODBC driver setup" interface, enter the custom server name in the connection form, for example, "informix_server_name ".

4. In the connection form on the "IBM Informix ODBC driver setup" interface, enter the custom host name, for example, "informix_server_ip ".

5. On the "IBM Informix ODBC driver setup" Page, enter the Custom Service name in the connection form, for example, "informix_service_name ".

6. In the connection form on the "IBM Informix ODBC driver setup" interface, select the protocol name, for example, "onsoctcp ".

7. On the "IBM Informix ODBC driver setup" interface, fill in the custom database name in the connection form, for example, "informix_dbname ".

8. On the "IBM Informix ODBC driver setup" Page, enter the Custom User ID value in the connection form, for example, "Informix ".

9. On the "IBM Informix ODBC driver setup" interface, fill in the Custom password value in the connection form, for example, "Informix ".

After completing the preceding settings, click Apply @ test connection. The prompt "test connection was successful" appears. The connection is successful. Click OK to complete all settings.

 

Open vs2008, create an application form, add a button, double-click the button, and enter the following code for testing:

Try
{
Odbcconnection conn = new odbcconnection ();
Conn. connectionstring = "DSN = custom DSN name; driver = {Informix 3.70 64 bit}; host = Linux Server IP address; server = Lin; service = Linux Database Service name; protocol = onsoctcp; database = Name of the database in Linux; uid = database user in Linux; Pwd = Database Password in Linux ";
Conn. open ();

String strsql = "select tabname from baoxiao: Informix. Tables Ables where Tabid> 99 and tabtype = 't'order by tabname ";
Odbcdataadapter adapter = new odbcdataadapter (strsql, Conn );
Dataset DS = new dataset ();
Adapter. Fill (DS, "data ");
// Bind all table field data to datagridview1
This. Maid = NULL;
This. Maid = Ds. Tables [0];
This. Maid ();

Conn. Close ();
MessageBox. Show ("tested ");
}
Catch (exception ex)
{
MessageBox. Show ("connection failed" + ex. Message );
}

 

Appendix: Informix software: ftp.software.ibm.com/software/data/informix/downloads/

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.