Quantcast
Channel: Catch SqlException
Viewing all articles
Browse latest Browse all 5

Catch SqlException

$
0
0

I have a Visual Studio Express 2010 c# application using Ling-SQL.  I'm getting a login failure, so I added a try-catch as follows:

try
{
      Execute a Get stored procedure to read data from a table
}
catch(SqlException sqlEx)
{
      log an error
}

But instead of  hitting the SqlException, I get a pop up box:
   SqlException Occurred
   Cannot open user default database. Login failed.
   Login failed for user 'Harry'

This code does work for a valid user. I am purposely creating this error because I need to catch SqlExceptions. 

The other issue is that the error does not appear in the SQL Server log.  Is there some option for logging that I am missing?


Harry T Ulmer


Viewing all articles
Browse latest Browse all 5

Latest Images

Trending Articles





Latest Images