RE: Duplicate Connections

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I just ran a test using the following code and it created a single connection
and only a single SPID as shown in SQL Server Ent Mgr's Current Activity
view. What does your code look like?

string sConnString = "Server=MyServer;Database=Northwind;Integrated
Security=True";
string sSql = "SELECT CategoryID, CategoryName FROM Categories ORDER BY
CategoryName";
using (SqlConnection cn = new SqlConnection(sConnString))
using (SqlCommand cmd = new SqlCommand(sSql, cn))
{
cn.Open();
using (SqlDataReader rdr = cmd.ExecuteReader())
while (rdr.Read())
{
// do something in here
}
}



// John Papa
// http://codebetter.com/blogs/john.papa



"DavidM" wrote:

> I am using the SQLConnection object to establish a connection a SQL Server
> 2000 PC running on my local PC. Whenever I open the connection I get two
> loggins on the SQL Server. Does anyone know what is causing this to happen?
.



Relevant Pages

  • SQL Server ODBC and multiple threads
    ... I am currently having problems with MS SQL server runiong on mutiprocessor ... connection handle I get the following error: ... Does it mean that I can not use a single connection with multiple ... possible to use one connection handle in multiple threads? ...
    (microsoft.public.data.odbc)
  • how to fix error "Connection is busy with results for another hstmt"
    ... I am using OleDB connection in vc++ code to insert data in sql server ... Single connection is being used by multiple threads to insert ...
    (microsoft.public.sqlserver.server)
  • How to fix error "Connection is busy with results for another hstmt"
    ... I am using OleDB connection in vc++ code to insert data in sql server ... Single connection is being used by multiple threads to insert ...
    (microsoft.public.sqlserver.odbc)
  • Re: Error "SQL Server does not allow remote connections"
    ... The application could not connect to the sql server db. ... network is blocking the connection. ... SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 ... integratedSecurity, SqlConnection owningObject) +737554 ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Connection from remote computer to network SQL Server
    ... There is no firewall on the W2K machine acting as the SQL server. ... I tried making the SQL machine a "trusted" on the router. ... connection works. ... To find the IP address of your computer inside the network, ...
    (microsoft.public.access.adp.sqlserver)