再来一篇关于NET连接Informix Database的文章

原文:

http://www-1.ibm.com/support/docview.wss?uid=swg21192027

Microsoft Visual Studio .NET C # code example that opens a connection to a IBM Informix Database using the IBM Informix .Net Provider.

Problem
This 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.
 
 
Solution

INTRODUCTION

This 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.

     

    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值