You are the first person to pick up my question and then you told me don't know IBM. Could you please let me know who i should look for?
Original Message:
Sent: Fri June 23, 2023 06:09 PM
From: John Robinson
Subject: Connecting to IBM i with C sharp on .NET 7 (old version called .NET Core)
Afraid not meaning I don't have any more advice...
The above lines worked in .net core 6...
As I don't work for IBM, you'll have to find better examples on the web for DB2.
------------------------------
John Robinson
Original Message:
Sent: Fri June 23, 2023 05:59 PM
From: Bruce Ma
Subject: Connecting to IBM i with C sharp on .NET 7 (old version called .NET Core)
Hi John,
what do you mean by "Afraid not"?
Do you mean that it is not impossible to connect to IBM i db2 with Net.IBM.Data.Db2 (7.0.0.200)?
the site you provided seems not using IBM.EntityFrameworkCore.
the example on the site is based on .NET Core 3.1 which is supported anymore.
Can you please give me an example with detailed information?
Thank you so much,
Bruce
------------------------------
Bruce Ma
Original Message:
Sent: Fri June 23, 2023 03:47 PM
From: John Robinson
Subject: Connecting to IBM i with C sharp on .NET 7 (old version called .NET Core)
Afraid not. Try Entity Framework?
https://stackoverflow.com/questions/62880235/ibm-data-db2-core-setup-procedure
Since my test app doesnt have dependency injection, it news up a dbcontext like:
var optionsBuilder = new DbContextOptionsBuilder<MyDBContext>();
optionsBuilder.UseDb2(connectionString, d => d.SetServerInfo(IBMDBServerType.YOURTYPE, IBMDBServerVersion.YOURVERSION));
var ecfDbContext = new MyDBContext(optionsBuilder.Options);
dbcontext:
public
partial class MyDBContext : DbContext
{
public DbSet<TableClass> Table { get; set; }
public MyDBContext(DbContextOptions<MyDBContext> options)
: base(options)
{
}
}
------------------------------
John Robinson
Original Message:
Sent: Fri June 23, 2023 03:22 PM
From: Bruce Ma
Subject: Connecting to IBM i with C sharp on .NET 7 (old version called .NET Core)
Hi John,
thank you for your quick response. i tried your suggestion and changed the connection string from UserID to User ID and added port number 446. it was still the same error with or without port number.
this error seems not reach license issue yet.
Do you have any advice?
Thank you,
Bruce
------------------------------
Bruce Ma
Original Message:
Sent: Fri June 23, 2023 02:17 PM
From: John Robinson
Subject: Connecting to IBM i with C sharp on .NET 7 (old version called .NET Core)
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
Original Message:
Sent: Fri June 23, 2023 12:29 PM
From: Bruce Ma
Subject: Connecting to IBM i with C sharp on .NET 7 (old version called .NET Core)
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
------------------------------