IntroductionThis document provides a Microsoft Visual Studio. net c # code example that opens a connection to a IBM Informix database using the IBM Informix. net provider. Before you begin This document assumes you have Microsoft Visual Studio. NET or Microsoft Visual Studio. NET 2003 installed. It also assumes you have IBM Informix Client SDK 2.81.tc3 or greater installed. The IBM Informix. net provider uses the setnet32.exe registry values to resolve connection information. This document assumes you have entered you informixserver connection information using setnet32.exe
Steps 1. copy file class1.cs.txt to working directory and rename to class1.cs: 2. Edit class1.cs and modify the connstring value as noted in the code comments. 3. Open a Visual Studio. NET Command Prompt window click
Start --> programs --> Microsoft Visual Studio. NET --> Visual Studio. NET tools --> Visual Studio. NET Command Prompt
4. Set informixdir equal to the path of you IBM Informix Client install directory.
> Set informixdir = C:/sdk281/bin
5. Add informidir/bin to your path.
> Set Path = % informixdir %/bin; % PATH %
6. Compile class1.cs.
> CSC/R: % informixdir %/bin/IBM. Data. Informix. dll class1.cs
7. Run class1.exe.
> Class1.exe
Using: Server = ol_strongright; database = stores_demo; uid = caryw; password #####
Success!
Common Problems
Symptom:Compile error: Error cs0006: Metadata File 'ibm. Data. Informix. dll 'could not be found
> CSC/R: IBM. Data. Informix. dll class1.cs Microsoft (r) Visual C #. Net compiler version 7.10.3052.4 For Microsoft (R). Net Framework Version 1.1.4322 Copyright (c) Microsoft Corporation 2001-2002. All rights reserved.
Error cs0006: Metadata File 'ibm. Data. Informix. dll 'could not be found
Resolution:Specify path to IBM. Data. Informix. dll > CSC/R:% Informixdir %/Bin/IBM. Data. Informix. dll class1.cs
Symptom:Unhandled exception at runtime > Class1.exe
Unhandled exception: system. Io. filenotfoundexception: file or assembly name IBM. Data. Informix, or one of its dependencies, was not found. File Name: "IBM. Data. Informix"
Resolution:IBM. data. informix driver does not exist in GAC (Global Assembly Cache ). see the document 'installing. net provider 'Listed in the related URL section of this page for information on resolving this driver problem.
|