Connection testing

  • Thread starter Thread starter Scott B
  • Start date Start date
S

Scott B

Can someone perhaps give me some insight as to why I am getting an
OleDbexception when I try to run the following code.
What I am looking to do is test if the connection could be opened and if
not, then have it fall back to a seccondary connection string.

However whenever I try to test the connection I get an OleDbconnection
exception....

OleDbConnection m_Conn = new OleDbConnection();
m_Conn.ConnectionString = ConnString;
m_Conn.Open();

if(m_Conn.State != ConnectionState.Open)
{
}
 
I should add that if the connection fails to open you will get an exception.
Read the properties of the OleDbConnection to determine why it failed.

Use a try/catch on the Open() and try the other connection if it fails.
 
I should add that if the connection fails to open you will get an exception.
Read the properties of the OleDbConnection to determine why it failed.

Ah, I mean the properties of the OleDbException.
 
What is the specific exception message generated?

You may have an underlying connection that is not closed.

Can you post the specific connection exception message generated

Thanks
 
Back
Top