ASP.NET, SQL Connection error handling

Results 1 to 3 of 3

Thread: ASP.NET, SQL Connection error handling

  1. #1
    Join Date
    Dec 1969

    Default ASP.NET, SQL Connection error handling

    I&#039;m using error handling in this fashion (, VB, communicating with SQL Server):<BR><BR><BR>Sub DoSomething( )<BR> On Error GoTo ErrorHandler<BR><BR> ObjConn.Open()<BR> (code to communicate with database)<BR> ObjConn.Close()<BR><BR> Exit Sub<BR><BR> Errorhandler:<BR> (error handling code)<BR><BR>End Sub<BR><BR><BR>My questoin is: if an error arises, will the database connection will stay open? I&#039;ve expereinced performance problems in the database connections in my application, and I suspect it may be because a lot of connections are opened but never closed?<BR><BR>Any suggestions?<BR><BR>Regards<BR>Torbjörn

  2. #2
    Join Date
    Dec 1969

    Default I'd use the new..

    .. Try.. Catch.. Finally method:<BR><BR>Sub DoSomething()<BR><BR> Try<BR> objConn.Open()<BR> Catch x As Exception<BR> &#039;error occurred<BR> Finally<BR> objConn.Close()<BR> objConn = Nothing<BR> End Try<BR><BR>End Sub

  3. #3

    Default RE: ASP.NET, SQL Connection error handling

    DataReaders have issues with unclosed connections.<BR>If you use only a connection string, there is no connection object to clean up ;)<BR><BR>If you are using SQL Server, you should use the Data Access Application Block.<BR><BR><BR><BR>Prevent pool overflows that can drown your applications<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts