closing connections



Hi,

I have a VB .NET program that uses ADO SqlClient dataadapters and MS SQLS.
It uses the Master db to return the names of attached databases, and then
connects to each one to check whether it is a specific type of database or
not by looking for a specific table (any ideas of a better way to do this
would be welcomed).

The problem I am having is closing my connections. Despite the fact that I
explicitly close and dispose each connection (see code below), the number of
connections as measured in SQLServer:GeneralStatistics - 'User connections'
in SQL Server Profiler keeps growing. The user connections only seem to
close when I close my app. This is a problem as in some case we have over
1000 databases on the server. How do I ensure that these connections are
always closed?!

Any assistance/thoughts much appreciated.

Dim cnn As SqlConnection = New SqlConnection(strcnn)

Dim adpSQLS As SqlDataAdapter = New SqlDataAdapter

Dim cmd As SqlCommand = New SqlCommand(strSQL, cnn)

Try

cmd.CommandTimeout = 10000

adpSQLS.SelectCommand = cmd

cnn.Open()

adpSQLS.Fill(dst, strdtbName)

Return dst.Tables(strdtbName)

Catch expSql As SqlException

UI.WriteErrorLogs("PopulateDataset", expSql)

Finally

If Not cnn Is Nothing Then cnn.Close()

If Not cnn Is Nothing Then cnn.Dispose()

If Not adpSQLS Is Nothing Then adpSQLS.Dispose()

If Not cmd Is Nothing Then cmd.Dispose()

End Try


.



Relevant Pages

  • Re: closing connections
    ... > The problem I am having is closing my connections. ... > Dim cnn As SqlConnection = New SqlConnection ... > Dim cmd As SqlCommand = New SqlCommand ...
    (microsoft.public.data.ado)
  • Re: Number of concurrent users
    ... limited to 10 connections. ... local copy of the frontend (forms, queries, reports, code) that is stored on ... My applications link to 10 backend databases to generate the reports. ...
    (microsoft.public.access.formscoding)
  • Re: Unable to log into the database
    ... two databases one is Interbase, ... I can open the connections in the server explorer connect ... THis leads me to believe that it is a security iss. ...
    (microsoft.public.vb.database)
  • Re: Unable to log into the database
    ... two databases one is Interbase, ... I can open the connections in the server explorer connect ... THis leads me to believe that it is a security iss. ...
    (microsoft.public.vb.database.ado)
  • Re: Which Database
    ... duty" databases at. ... 10 or 20 connections concurrently with little problem (personally ... extra moneys for special licensing. ... Microsoft Windows OS, so Microsoft gets their money through the ...
    (comp.databases)