469,077 Members | 1,380 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,077 developers. It's quick & easy.

Open SQL 2005 database question

Shoud a SQL 2005 database remain open in a Visual Basic program, or should
it be opened and closed in every subroutine?

Thanks for any info.
Oct 29 '07 #1
3 1263
Charlie wrote:
Shoud a SQL 2005 database remain open in a Visual Basic program, or should
it be opened and closed in every subroutine?
How often will the VB program access the database?
Oct 30 '07 #2
Charlie (ja******@yahoo.com) writes:
Shoud a SQL 2005 database remain open in a Visual Basic program, or should
it be opened and closed in every subroutine?
You don't really open or close the database, but you connect and disconnect
from the server.

It's common to do as you say open and disconnect. It's not really cheap to
open a connection to SQL Server. However, the client API maintains a
connection pool, so behind the scenes the connection is open, and is reused
when you connect anew. (If there is no connection for a certain amount of
time, typically 60 seconds, the connection is closed for real.)

Then again, in a two-tier application it's not really any major flaw to
have a global connection that you keep open.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Oct 30 '07 #3
Very frequently.

"Ed Murphy" <em*******@socal.rr.comwrote in message
news:47***********************@roadrunner.com...
Charlie wrote:
>Shoud a SQL 2005 database remain open in a Visual Basic program, or
should it be opened and closed in every subroutine?

How often will the VB program access the database?

Oct 30 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by dennist685 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.