473,387 Members | 1,553 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Connection testing

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)
{
}

Nov 16 '05 #1
4 1478
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

--
http://www.visual-basic-data-mining.net/forum
data mining and .net team
"Scott B" <NoSpamPlease> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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)
{
}

Nov 16 '05 #2
Hi Scott,

The exception type and message and the content of the connectionstring would be nice.
You can see if your connection string was correct using samples on this site.

http://www.connectionstrings.com/

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #3
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.

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #4
On Wed, 08 Sep 2004 08:23:11 +0200, Morten Wennevik <Mo************@hotmail.com> wrote:
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.

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Jozef | last post by:
Hello, Is there a way to test that an internet connection exists and that you are able to see the webserver before performing any connections? The reason being, when I try to connect to an SQL...
5
by: Dmitry Karneyev | last post by:
Hi All! I've got an ado.net app with several win forms. In the first form (form1) I connect to DB and in other forms I use connection string generated by the form1 and stored in sqlconnection...
9
by: AccessStarters | last post by:
Can anyone please help me simply connect to northwind? Maybe some logical steps that I may be missing? I have tried many tutorials and they all give similar connections to the one below. Dim...
7
by: Steve Franks | last post by:
Using VS.NET 2005 RC - Am I understanding correctly from the docs that connection pooling for my ADO.NET db connections will happen automatically? Do I need to do anything to enable this feature? ...
1
by: James Goodman | last post by:
In VB6 I used to set my applications to automatically look for the source DB in the program installation directory. If it wasnt found it was fairly easy to pop a dialog asking the user to specify the...
35
by: Eric Sabine | last post by:
In my Finally block, I was using cn.close (where cn is an ADO.NET connection object, SQLConnection to be exact) and then I came across the following in some microsoft code. If Not cn Is Nothing...
15
by: ezmiller | last post by:
Does anybody know how to use javascript to test whether or not an internet connection exists? Is this possible even?
4
by: obmij | last post by:
Hi all, I am a WAMP newbie and would appreciate your help! I have installed Apache 2.2.4, Mysql 5 and PHP 5 have got them all up and running and tested them separately, I was able to do the...
3
by: =?Utf-8?B?Sm9obkJhdGVz?= | last post by:
I'm trying to (programatically) backup and clear the security event log on the local machine. I can do this manually through the event viewer and I am logged on as an administrator. I can...
0
by: Alexnb | last post by:
Timothy Grant wrote: well I can tel you it didn't work for me. In fact I didn't see the code you posted on there, I ended up figuring it out on my own with a little help from the missing manual...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.