4

I've been having some difficulty connecting to an iseries DB2 database from a .net 4.0 application I'm developing. I've been trying to use the IBM.Data.DB2.dll library to connect to it using the following code;

String connectionString = "Database=[DBName];UserID=[UserID];Password=[Password];Server=[ServerName]";
connection = new DB2Connection(connectionString);
connection.Open();

When the connection.Open() command is run I receive the following error:

ERROR [58009] [IBM] SQL30020N Execution of the command or SQL statement failed because of a syntax error in the communication data stream that will affect the successful execution of subsequent commands and SQL statements: Reason Code "0x124C"("0100")"". SQLSTATE=58009

Does anyone know of another way of connecting to this kind of database in .net?

3
  • Might be a version mismatch between you DB2 client version, DB2 Connect version, and/or iSeries version. Commented Sep 29, 2014 at 15:59
  • 1
    www-03.ibm.com/systems/power/software/i/access/windows/… Commented Sep 29, 2014 at 16:51
  • Could you suggest another way I can connect to the database? Commented Sep 30, 2014 at 15:11

2 Answers 2

5

This works for me:

class Program
{
    static void Main(string[] args)
    {
        string connString = "DataSource=SYSTEM;UserID=USER;Password=PASSWORD";
        iDB2Connection conn = new iDB2Connection(connString);
        conn.Open();

        string cmdString = "CRTPF FILE(TESTLIB/TESTNET) RCDLEN(100)";
        string cmdText = "CALL QSYS.QCMDEXC('" + cmdString + "', " + cmdString.Length.ToString("0000000000") + ".00000" + ")";

        iDB2Command cmd = new iDB2Command(cmdText, conn);
        cmd.ExecuteNonQuery();
        cmd.Dispose();

        conn.Close();
    }
}
Sign up to request clarification or add additional context in comments.

Comments

0

We are using Data Direct DB2 driver from Progress. This supports Entity Framework. May be you can try with that. You can download the evaluation version online (progress.com)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.