Global Data Management Forum

 View Only
Expand all | Collapse all

Connecting to IBM i with C sharp on .NET 7 (old version called .NET Core)

  • 1.  Connecting to IBM i with C sharp on .NET 7 (old version called .NET Core)

    Posted Fri June 23, 2023 01:33 PM

    Hi IBM DB2 Team,

    My applications work fine on .NET Framework 4.8 with IBM.Date.DB2.iSeries.dll from IBM i Access Client Solutions.

    i am trying to migrate my applications from .NET Framework 4.8 to .NET 7.

    here is my environment:

    IBM i: V7.4

    .NET 7

    Windows 2016 server

    visual studio 2022 (C sharp)

    i created a simple console application in VS on .NET 7 and installed Net.IBM.Data.Db2 (7.0.0.200).

    Here is my code:

    using System.Data.Common;
    using System.Data;
    using IBM.Data.Db2;

    using (DB2Connection iDB2Conn = new DB2Connection("Server=IP_ADDRESS;database=Databasename;UserID=DUMMY;Password=DUMMY;"))
    using (DB2Command iDB2Cmd = new DB2Command())
    {

        iDB2Conn.Open();
        iDB2Cmd.Connection = iDB2Conn;

    }

    Here is the error message:

    IBM.Data.Db2.DB2Exception
      HResult=0x80004005
      Message=External component has thrown an exception.
      Source=IBM.Data.Db2
      StackTrace:
       at IBM.Data.Db2.DB2ConnPool.Open(DB2Connection connection, String& szConnectionString, DB2ConnSettings& ppSettings, Object& ppConn)
       at IBM.Data.Db2.DB2Connection.Open()
       at Program.<Main>$(String[] args) in C:\TestProject\ApiTest\ApiTest\Program.cs:line 13

    Could anybody shed light on this issue?

    i appreciate any help!

    Bruce



    ------------------------------
    Bruce Ma
    ------------------------------


  • 2.  RE: Connecting to IBM i with C sharp on .NET 7 (old version called .NET Core)

    Posted Fri June 23, 2023 02:18 PM

    I'm connecting to an Informix db w/ entity framework... 

    comparing your connection string, we have a space in 'User ID='...  User<SPACE>ID=....
    we also have a port  in the Server=address:port ... maybe its default and yours aren't the same

    I've seen other posts/issues on here about licenses... 



    ------------------------------
    John Robinson
    ------------------------------



  • 3.  RE: Connecting to IBM i with C sharp on .NET 7 (old version called .NET Core)