Web Control Error Handling

MrTee

Newcomer
Joined
Nov 22, 2004
Messages
1
I'm using Visual Studio .NET to create an ASP.NET app with database access. I've set up the database access using the Visual Studio .NET web controls that are provided (SQLConnection, SQLDataAdapter, etc.)

My problem is that I'm not sure how to catch connection errors. The code that handles the database connections is generated by Visual Studio.

Is there a way to catch and handle these errors?
 
You'll need to place a try/catch block around the code that generates the exception.

Visual Basic:
Try
     connection.Open()
Catch sqlEx As SqlException
     Log.Write(sqlEx)
Finally
     If Not connection Is Nothing
          connection.Close()
          connection.Dispose()
     End If
End Try
 
Back
Top