VB to SQL Server Connection

  • Hi Friends,

    I'm Developing a software application in VB font-end with SQL Server Backend. I'm using ADODB connection. The application consist of 32 forms. Now my doubt is regarding the connection to DB. Should I keep a single connection throughout the Application or connect each time while performing INSERT/UPDATE/DELETE action.

    Pls help

    cheer up

    Manoj

    P.B. No 14337

    Doha - Qatar

    Ph: 4435361

    web:www.fccqatar.com


    P.B. No 14337
    Doha - Qatar
    Ph: 4435361
    web:www.fccqatar.com

  • The answer is it depends. For a highly scalable app you'll want to open and close the connection as needed. For less intense apps I see nothing wrong with holding a connection for the duration. I definitely encourage you to use stored procs for the data changes regardless of which connection strategy you use.

    Andy

    http://qa.sqlservercentral.com/columnists/awarren/

  • You should be able to keep the connection for the duration of the application without issue. The only extra things you may want to do is set a connection timeout to ensure will close itself if left sitting idle for a long period and do a connection state check before each query action and if returns closed reopen then else run your process. As long as you are not eating up you connections beyond what you have license for leaving it open only helps speed. However closing may not hurt performance either as long as you do not destroy you connection object (Ex. objConn = nothing), what happens is as long as the connection object is not destroyed it will be added to the connection pool. Then when called again the connection can open as though it never closed (which technically I believe it didn't), but the connection will drop automatially when the app is closed.

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply