SQL connection opening two connections

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a question about Sql. When I run a simple open statement for a SQL database, it opens up two connections sometimes, and other times it opens up one connection. Does anyone know why this happens. Below is my source code where this is occuring. You will have to change the connection string, especially the Database and ServerName. Any help will be appreciated.

When you run the code, when the message box pops up, check the number of connections that have appeared in the sysprocesses table. There will be one or maybe two. It is really fustrating

Dim SQL_Connection As SqlClient.SqlConnectio
Dim connection_string As Strin

connection_string = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=DatabaseName;Data Source=ServerName; Application Name = 'TestConnection'

SQL_Connection = New SqlClient.SqlConnection(connection_string
SQL_Connection.Open(

MessageBox.Show("The connection is open."

SQL_Connection.Close(

Thank you for your help
 
Stab in the dark - but could it something to do with clustered servers?

Christopher said:
I have a question about Sql. When I run a simple open statement for a SQL
database, it opens up two connections sometimes, and other times it opens up
one connection. Does anyone know why this happens. Below is my source code
where this is occuring. You will have to change the connection string,
especially the Database and ServerName. Any help will be appreciated.
When you run the code, when the message box pops up, check the number of
connections that have appeared in the sysprocesses table. There will be one
or maybe two. It is really fustrating.
Dim SQL_Connection As SqlClient.SqlConnection
Dim connection_string As String

connection_string = "Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=DatabaseName;Data Source=ServerName; Application
Name = 'TestConnection'"
 
Chris, I think this is b/c connection pooling. Turn it off just to test and
see if you get the same behavior.
Christopher said:
I have a question about Sql. When I run a simple open statement for a SQL
database, it opens up two connections sometimes, and other times it opens up
one connection. Does anyone know why this happens. Below is my source code
where this is occuring. You will have to change the connection string,
especially the Database and ServerName. Any help will be appreciated.
When you run the code, when the message box pops up, check the number of
connections that have appeared in the sysprocesses table. There will be one
or maybe two. It is really fustrating.
Dim SQL_Connection As SqlClient.SqlConnection
Dim connection_string As String

connection_string = "Integrated Security=SSPI;Persist Security
Info=False;Initial Catalog=DatabaseName;Data Source=ServerName; Application
Name = 'TestConnection'"
 
I thought that. But if it was connection pooling, wouldn't it have only one SQL server connection for multiple programmatic connections, rather than the other way round?
 
I believe this is due to pooling in ADO.
If you really don't want pooling, add 'pooling=false' to your connection string.

Read more at: http://msdn.microsoft.com/library/d...nectionpoolingforsqlservernetdataprovider.asp

and

http://www.sql-server-performance.com/sk_connection_pooling_myths.asp

Göran Israelsson
it.konsulter.alero.se
goeran dot israelsson at alero dot se


**********************************************************************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
 
Back
Top