SqlException

G

Guest

I have the following code to open a database. Since I don't have the db as
specified in the connectionString, the connection.Open() will throw an
SqlException. My question is why it opens the "SqlException occured" dialog
before it goes to the catch block? Is there a setting to turn the dialog off?
I am expecting to catch and handle the exception myself. I am in debug mode.

try
{
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
}
catch (Exception e)
{
}
 
M

Marina Levit [MVP]

This is the debugger doing this. Run your executable without debugging or
just outside of the IDE completely, it will behave as expected.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top