Results 1 to 9 of 9

Thread: Speeding up the execution of an App

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    153

    Post

    I created an application using ADO. After first completion, the App was starting up in 3 seconds. I've since added several modules (.bas) and forms to the App in which there is a connection to the database. Now my App is starting up in 35 seconds. Is there a particular order that I should reference the different parts of my App in order to optimize speed and performance.

    Thanks!

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    153

    Post

    I think I found where most of my problem is located, but not sure how to correct it. I have five modules (.bas) besides the code module for the form. On each module I'm opening and establishing a connection with the same database. The queries in each module are all from the same database. Just that the results go to different forms. Any ideas on best how to organize the setup of the App to optimize performance? I can remove the close connection and database from the form code, which would keep the database open I guess for other references.

    Thanks!

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Make the connection to your database global in any one of the modules, and it will be available to everything else in your program. Another way to speed up loading is to remove as much code as possible from forms, and put it in a module. Also if you have a lot of strings hard-coded for MsgBoxes, etc., consider using a res file instead.

    ------------------
    Marty

  4. #4
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    >There's a module for each form that opens a connection to the database.

    Eeek. That's your problem all right. You need to define your database as a global (open it once on your main form) and open different _recordsets_ for each module. Each open instance of your database slows down the next.

    [This message has been edited by JHausmann (edited 12-23-1999).]

  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Clunietp: I could be wrong, but I don't believe it makes any difference to program speed where you store your variables. But I do know that storing code in forms increases program load time, and that was the subject of the original question.


    ------------------
    Marty

  6. #6
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    Marty

    I have always thought that it is less efficient to store variables, objects and methods at the global scope, as opposed to a form scope or just procedure scope. Is this the case?

  7. #7
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    Marty

    If VB creates and destroys memory addresses for variables when they fall out of scope, then a variable declared at global scope would never be destroyed (and therefore still take up the memory). I suppose it would run faster, but would take up a lot more memory during app execution.

    Any one else want to confirm this for us?

    Thanks

    Tom

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    153

    Post

    I hear you guys, I believe I'm doing things inefficient, but being a newbie it's what works for me. I'm retrieving recordsets from a database for six different forms. There's a module for each form that opens a connection to the database. On each form are listboxes(27-55) that stores the retrieved values. So pretty much every module looks pretty much the same. There's not much coding under the form_load event, althought there's a connection to the database, and a combo.additems from the database. I will explore the .res file as an option.

    Thanks for your help!

    [This message has been edited by Hutty (edited 12-23-1999).]

  9. #9
    Addicted Member
    Join Date
    Dec 2002
    Location
    Malaysia
    Posts
    224
    I am working on an application that might load about 500-1000 or more records and puts it into the screen.
    I am currently using a ADO connection and i think, opening connection globally is good for me.

    But executing the sql statement had been slow. Is there a way to enhance the performance? I was advice to use Extended List to do the database control. What do you guys think ?

    Please Advice,
    leng wai

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width