Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Already opened DataReader
Message
From
11/03/2011 11:25:49
 
 
To
11/03/2011 11:10:51
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01503339
Message ID:
01503344
Views:
31
>>Everything in ADO.NET uses a DataReader. If, for example, you fill a dataset from SQLServer then a SQLDataReader is used behind the scenes.
>
>Since the debut I have been using .NET, I open my SQL Server connection in the Application.Initialize() method and refer to it as many times as I need. This avoids opening and closing the connection for everything request. This is why it is so fast. I do the same thing either for a desktop application or a Web application. On millions of hits and SQL Server requests, I got that one about 4 times in a year.
>
>So, is it an assumption that always using the same connection could create this situation after hundreds of thousands of SQL requests? If yes, if I open and close the connection for every SQL request, this will slow down the entire application.

It's just not good practice to keep a connection open for any longer than is neccessary. With connection pooling the connection is only released to the pool - not physically closed. Subsequent calls to Connection.Open() will be virtually instantaneous assuming there are connections available in the pool. If there are not then the worst that can happen is that a new one is created. There may be an argument for maintaining the same connection within a very tight loop. Maintaining a connection even for long enough to service a single request is not a good idea.......

There was a thread here recently which led me to test connection open/close timings. Rough results:
First Open : 117 milliseconds.
Total time for 10,000 subsequent open/close calls : 465 milliseconds.

I don't think there's much of a timing issue there ?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform