1

I'm very new with DB2 but have started a project that require to manipulate DB2 Database in AS400 v7r1 iSeries. I'm trying to use the IBM.Data.DB2.iSeries nuget to make a connection but no luck. My connection string in Web.config looks like

<add key="ConnectionString" value="Provider=IBMDA400;Password=pwd;User ID=user;Data Source=server_ip_add;Transport Product=Client Access;SSL=DEFAULT;Default Collection=default_schema"/> 

and I am using it like this:

var myConnection = new iDB2Connection(connectionString); 

The returned error is 'The connectionstring property is invalid' There are some other nugets named IBM.Data.Db2 and IBM.Data.Db.Provider but I haven't tried them. These seem to work with .NET 4.0 but I'm not sure they can work with AS400 v7r1.

I have tried using DSDriver and VSAI but cannot create an EF model.

Could you please give me some suggestions?

1 Answer 1

0

I'm using the following:

App.config:

<add key="iConnectionString" value="DataSource=MyMachine; UserID=TheUser; Password=ThePassword; Naming=System; CheckConnectionOnOpen=true; DataCompression=True; Pooling=False" /> 

using IBM.Data.DB2.iSeries; ...

connect:

 private iDB2Connection iCon; ... if (iCon == null || iCon.State != ConnectionState.Open) { try { iCon = new iDB2Connection(ConfigurationManager.AppSettings["iConnectionString"]); if (iCon == null) rv = false; else { iCon.Open(); if (iCon == null || iCon.State != ConnectionState.Open) rv = false; } } catch (iDB2CommErrorException ee) { //var Message = ee.MessageCode + ":" + ee.Message + "\n\rSQL-Status: " + ee.SqlState; rv = false; } } 

insert:

 try { iDB2Command iCmd = new iDB2Command("INSERT INTO EDIFSP (TFRNUM, FILENAME, PROCSTS, PROCDTTM, SND_ID, RCV_ID, TFRDIR, IFCTYPE, IFCVRSN, MAPNAME, CRTDTTM, TFRDTTM) " + "VALUES(@TFRNUM, @FILENAME, @PROCSTS, @PROCDTTM, @SND_ID, @RCV_ID, @TFRDIR, @IFCTYPE, @IFCVRSN, @MAPNAME, @CRTDTTM, @TFRDTTM)", iCon); iCmd.DeriveParameters(); iCmd.Parameters["@TFRNUM"].Value = fs.TransferNumber; iCmd.Parameters["@FILENAME"].Value = fs.FileName; iCmd.Parameters["@PROCSTS"].Value = fs.Status; iCmd.Parameters["@PROCDTTM"].Value = DateTime.Now; iCmd.Parameters["@SND_ID"].Value = fs.SenderID; iCmd.Parameters["@RCV_ID"].Value = fs.ReceiverID; iCmd.Parameters["@TFRDIR"].Value = fs.TransferDirection; iCmd.Parameters["@IFCTYPE"].Value = fs.InterfaceType; iCmd.Parameters["@IFCVRSN"].Value = fs.InterfaceVersion; iCmd.Parameters["@MAPNAME"].Value = fs.MappingName; iCmd.Parameters["@CRTDTTM"].Value = fs.CreationDateTime; iCmd.Parameters["@TFRDTTM"].Value = fs.TransferDateTime; iCmd.ExecuteNonQuery(); iCmd.Dispose(); } catch (iDB2SQLErrorException ee) { //var Message = ee.MessageCode + ":" + ee.Message + "\n\rSQL-Status: " + ee.SqlState; } catch (iDB2CommErrorException ee) { //var Message = ee.MessageCode + ":" + ee.Message + "\n\rSQL-Status: " + ee.SqlState; } 

Hope that helps. Be sure to have IBM.Data.DB2.iSeries.dll and IBM.Data.DB2.iSeries.xml in your project (or path)...

Sign up to request clarification or add additional context in comments.

1 Comment

The code is fine but I have to install IBM iAccess For Windows. Just the dll doesn't work for me

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.