Error: Connectionstring property is invalid RRS feed

  • Question

  • User-73514677 posted

    Hi .

    I am trying to use the IBM DB2 connection string to connect to a database. 

    I have added the IBM.Data.DB2.iSeries.dll  and used the using 

    using IBM.Data.DB2.iSeries;

    I am trying to establish a connection to a IBM Robot box. I have used the below code:

     private void IseriesConnect()
                    iDB2Connection connDB2 = new iDB2Connection();
                    connDB2.ConnectionString = @"Server = servername:port; Database = dbname; UID = userid; PWD = password";
                    iDB2Command idbc = new iDB2Command
                        ("select query", CommandType.Text,connDB2);
                catch (Exception eR)

    I am getting the error as Connectionstring property is invalid.

    How to fix this ?


    Tuesday, January 5, 2021 4:16 PM

All replies

  • User753101303 posted


    N!ot sure about DB2 but eR.ToString() rather than eR.Message could give addiitonal details about what exactly is wrong in your connection string.

    Seems pretty much fine according to the doc but I would suppress extra spaces (I assume port is an actual port number ?). you don't have = or ; in the actual password?

    nnDB2.ConnectionString = @"Server=servername:port;Database=dbname;UID=userid;PWD=password";
    Thursday, January 7, 2021 1:54 PM
  • User-73514677 posted


    Tried this connection string way.

    Same error: Connection property is invalid

    source: IBM.Data.Db2.iSeries

    message code: 0

    Friday, January 22, 2021 5:30 PM
  • User753101303 posted

    According to https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.swg.im.dbclient.adonet.ref.doc/doc/DB2ConnectionClassConnectionStringProperty.html it seems keyword are fine. I assume you are using a port number in the actual string?

    https://www.connectionstrings.com/db2-net-data-provider-db2connection/ shiows something similar?

    My last resort would be to add keywords one by one and see what happens. Or maybe the issue is that it misses a required keyword but that the error messaghe just tells the string is wrong.

    Ah it says tthat tthe ConnectionSrring or the Connecrion is invalid, on which line? Also the line of code on which it fails could help in case the problem woulld be not with the connecrtion string but a problem with the connection instead.

    Friday, January 22, 2021 6:20 PM
  • User303363814 posted

    I know nothing about DB2 but I know that connection strings can be a pain.  One trick I use is to create an empty file (on the desktop or anywhere) whose extension is .udl

    Double click the file and the "Data Link Propartie" dialog will open.  Now choose the Provider and set various connection string properties and test your work.  When clicking 'Test Connection' works then click OK to save your work.  Now use Notepad (or whatever) to open the .udl file.  There is the connection string you need.

    Friday, January 22, 2021 11:56 PM
  • User-73514677 posted

    The error is showing on this line:

                    connDB2.ConnectionString = @"Server = servername:port; Database = dbname; UID = userid; PWD = password";
    Saturday, January 23, 2021 3:49 AM
  • User303363814 posted

    It is not clear how basic your error is.  We all assume that what you have shown is not actually your connection string.  You do not have the characters 'servername' and 'port' and 'dbname', etc in the string do you?

    Have you tried the udl approach?  It is much easier and much more efficient than asking random people on the internet to guess which of the thousands of possible errors you have made.

    Saturday, January 23, 2021 11:16 PM