INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

VB & connection strings

VB & connection strings

(OP)
I am using VS 2008 with sql server 2008
I wish to write a small test app to try out my new found skills but have hit a brick wall.
I do not wish to use the binding adapters et al (so called VCR controls) but wish to utilise my ADO.net skills thru code.

My 'brick wall' is in the connection. Do I connect to the DB in startup (behind my flash screen) and then leave the connection open until the App closes OR do I connect to the DB on entry to each form and close on exit?

I am hoping this is a really easy question to answer as I am bamboozled by the amount of info out there.

I should point out that I have converted from Access 2007 and that is where my knowledge lies.

Many thanks for your help ...

Jon  

RE: VB & connection strings

I guess that'll depend on how much you intend to access the database.

I've got some programs that constantly send SQL statements and get recordsets via an ADO connection, so I start the connection as soon as the program starts and close it when the program ends.

Other programs will only need to use a particular database once, so those wait 'til the database is needed before opening the connection.

RE: VB & connection strings

This probably belongs in a VB.Net forum.


Generally though the answer "depends."

If the database access is infrequent compared with the life of the program, open/use/close connections.  If the nature of the program involves a lot of different updates fairly frequently use a connection open for the life of the program.

For example if the user interaction is patterned like a forum web site (retrieve, display, lots of think time, then an update is posted) using short connections can increase scalability.

However if lots of query/updating goes on in rapid succession the open/close overhead will limit scalability.

RE: VB & connection strings

I think there is a general thought / rule:

Connections are expensive. Recordsets are cheap.

This is, of course, with respect to the execution time, so the above advice fits to this thought in a general way, but may provide a background for the details.

 

MichaelRed


 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close