Vote count:
0
Given
I have the follow situation: During the runtime of my application I must be able to switch the database connection from an ODBC connection to a DB2 Connection and and conversely.
Problem
All my methods work fine. If i establish a connection to ODBC it works. If I establish a connection to Db2 it works fine. But if I try to connect to Db2 and afterwards to the ODBC driver I get an error that tells me he could not find the right database.
Example:
If I try this:
public void HelpMeTest() {
string odbcConnectionString = string.Format("DSN={0};UID={1};PWD={2};", "MY-DNS", "myUser", "pwd");
string db2ConnectionString = "Database=myDataBase;";
OdbcConnection odbcCon = new OdbcConnection(odbcConnectionString);
odbcCon.Open();
odbcCon.Close();
DB2Connection db2Con = new DB2Connection(db2ConnectionString);
db2Con.Open();
db2Con.Close();
}
It works fine. But it I try this:
public void HelpMeTest() {
string odbcConnectionString = string.Format("DSN={0};UID={1};PWD={2};", "MY-DNS", "myUser", "pwd");
string db2ConnectionString = "Database=myDataBase;";
DB2Connection db2Con = new DB2Connection(db2ConnectionString);
db2Con.Open();
db2Con.Close();
OdbcConnection odbcCon = new OdbcConnection(odbcConnectionString);
odbcCon.Open();
odbcCon.Close();
}
I get an error during odbcCon.Open(); which tells me that my database is in the wrong format, because he thinks that MY-DNS is the name of the database and not a DSN.
ERROR [HY501] [IBM][CLI Driver] SQL1001N "MY-DNS" is not a valid database name. SQLSTATE=2E000
Some ideas?
asked 45 secs ago
Aucun commentaire:
Enregistrer un commentaire