Specify the DB2 query schema / instance in the connection string

I am trying to specify a default schema / instance as part of a connection string (or a specific command), so it should not be part of the request.

OdbcConnection conn = new OdbcConnection("Driver={IBM DB2 ODBC DRIVER}; Database=myDB; Hostname=myHostName; Port=myPort; Protocol=TCPIP; Uid=myID; Pwd=myPW;");
OdbcCommand comm = new OdbcCommand("select count(*) from customers", conn);
conn.Open();
var value = comm.ExecuteScalar();
conn.Close();

Unfortunately, this is not an error:

ERROR [42S02] [IBM] [CLI driver] [DB2] SQL0204N myID . Clients is an undefined name. SQLSTATE = 42704.

Note the use of myID where the schema / instance should be. If I specify schema / instance explication:

OdbcCommand comm = new OdbcCommand("select count(*) from mySCHEMA.customers", conn);

works as expected. I would like to indicate mySCHEMAas part of the connection string similar to the "Start Directory" when using MS SQL Server.

After a bunch of experimentation and googling, I can't figure it out. Any ideas?

+3
source
1

, . CurrentSchema = mySCHEMA .

- http://www.connectionstrings.com/ibm-db2 ( , Schema, Default ..). , - ...

+6

All Articles