Click here to Skip to main content
15,909,939 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionExeption handling in VB.net Pin
supercat914-Nov-07 6:19
supercat914-Nov-07 6:19 
AnswerRe: Exeption handling in VB.net Pin
Dave Kreskowiak14-Nov-07 6:57
mveDave Kreskowiak14-Nov-07 6:57 
GeneralRe: Exeption handling in VB.net Pin
supercat914-Nov-07 9:02
supercat914-Nov-07 9:02 
GeneralRe: Exeption handling in VB.net Pin
Dave Kreskowiak14-Nov-07 10:20
mveDave Kreskowiak14-Nov-07 10:20 
GeneralRe: Exeption handling in VB.net Pin
supercat914-Nov-07 10:45
supercat914-Nov-07 10:45 
GeneralRe: Exeption handling in VB.net Pin
Dave Kreskowiak14-Nov-07 10:53
mveDave Kreskowiak14-Nov-07 10:53 
GeneralRe: Exeption handling in VB.net Pin
supercat914-Nov-07 12:05
supercat914-Nov-07 12:05 
AnswerRe: connection to SQL server stays open Pin
Dave Kreskowiak14-Nov-07 6:11
mveDave Kreskowiak14-Nov-07 6:11 
ADO.NET maintains an open connection to the server, even if your code closed it. This is so that the next connection that uses the same connection string can be made faster without having to rebuild the entire connection with the SQL server. This is called "connection pooling".

If the "closed" connection in the pool goes unused, it will eventually be dropped. I think the default is 15 seconds, afterwhich the connection is SCHEDULED to be dropped. It might not drop right away.

You can force the connection to be dropped yourself if you call the ClearPool method after you close your connection:
Dim conn As New SqlConnection(...)
.
.  Do your database query stuff...
.
conn.Close()
conn.ClearPool()

Or you can specify the Pooling option in the connection string to tell ADO.NET not to pool that connection:
Persist Security Info=False;Initial Catalog=Northwind;server=SomeServer; Pooling=False





A guide to posting questions on CodeProject[^]

Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


QuestionNibbles Pin
No-e14-Nov-07 6:05
No-e14-Nov-07 6:05 
AnswerRe: Nibbles Pin
Dave Kreskowiak14-Nov-07 6:26
mveDave Kreskowiak14-Nov-07 6:26 
GeneralRe: Nibbles Pin
supercat914-Nov-07 6:30
supercat914-Nov-07 6:30 
GeneralRe: Nibbles Pin
Dave Kreskowiak14-Nov-07 6:49
mveDave Kreskowiak14-Nov-07 6:49 
GeneralRe: Nibbles Pin
supercat914-Nov-07 6:56
supercat914-Nov-07 6:56 
GeneralRe: Nibbles Pin
Dave Kreskowiak14-Nov-07 7:16
mveDave Kreskowiak14-Nov-07 7:16 
GeneralRe: Nibbles Pin
supercat914-Nov-07 9:40
supercat914-Nov-07 9:40 
GeneralRe: Nibbles Pin
Dave Kreskowiak14-Nov-07 12:57
mveDave Kreskowiak14-Nov-07 12:57 
GeneralRe: Nibbles Pin
nlarson1114-Nov-07 7:40
nlarson1114-Nov-07 7:40 
GeneralRe: Nibbles Pin
Dave Kreskowiak14-Nov-07 8:22
mveDave Kreskowiak14-Nov-07 8:22 
GeneralRe: Nibbles Pin
nlarson1114-Nov-07 8:26
nlarson1114-Nov-07 8:26 
Questionform closing error Pin
Tom Deketelaere14-Nov-07 4:07
professionalTom Deketelaere14-Nov-07 4:07 
AnswerRe: form closing error Pin
Dave Kreskowiak14-Nov-07 6:24
mveDave Kreskowiak14-Nov-07 6:24 
Questionconnection to SQL server stays open Pin
Tom Deketelaere14-Nov-07 3:32
professionalTom Deketelaere14-Nov-07 3:32 
AnswerRe: connection to SQL server stays open Pin
Colin Angus Mackay14-Nov-07 5:56
Colin Angus Mackay14-Nov-07 5:56 
QuestionBarcode Pin
Naderrafiee14-Nov-07 1:48
Naderrafiee14-Nov-07 1:48 
AnswerRe: Barcode Pin
Boroumandan14-Nov-07 2:08
Boroumandan14-Nov-07 2:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.