RE: Duplicate Connections
- From: John Papa <JohnPapa@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 12 Apr 2005 08:36:02 -0700
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?
.
- Follow-Ups:
- RE: Duplicate Connections
- From: DavidM
- RE: Duplicate Connections
- References:
- Duplicate Connections
- From: DavidM
- Duplicate Connections
- Prev by Date: RE: DataSet Transactions Help
- Next by Date: Re: DataSet Transactions Help
- Previous by thread: Duplicate Connections
- Next by thread: RE: Duplicate Connections
- Index(es):
Relevant Pages
|