|
-
Aug 24th, 2011, 07:25 AM
#2
Re: SQL Server Connections - Best Practice
Generally speaking, the idea is that connections should only be open for as long as necessary to do what needs to be done to the database. ADO.NET is designed to operate primarily in a disconnected state... you open a connection, get your data and close the connection. The app does what it needs to do on the data in memory. then you open the connection, update the database, close the connection.
That said....
Let's say you have to select data from three table when your app starts.
Do not do this:
open
select
close
open
select
close
open
select
close
Do it like this instead
open
select
select
select
close
Does that help?
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|