Discussion Locked

How do I speed up my VB6 application?

0 helpful
9 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I wrote my first full VB6 program that is pulling reports from an Access database. I have one connection (ado), and several recordsets that I am using. I have made sure to close each recordset and set it to Nothing at the end of each sub or function that uses it. Is there anything else I can do to speed the program up?
1. The user makes selections from a vb form.
2. These selections help determine the recordset (via an sql statement) that is passed to Crystal Reports 7.

Would appreciate any suggestions, or let me know if you need more details. I am mainly looking for general efficiency things to look for!

9 replies

by sl-campbell

This is really a big subject and would be wrong to limit it to an answer block here.
There are tons of factors and it starts with the basics and can go into very indepth programming techniques, from using standards and getting rid of unused variables, to how an SQL statement is built, one way being more efficient than the other, and using the correct resources for the program. It can also get very "picky". It is also a cost and time factor vs. what the program should accomplish and how big theprogram and functionality will be needed.

It would be silly to create a recordset with-out any restrictions which returns 100,000 records, then loop through each record in order to find a one certain name that you are looking for, and only need that one record. It would also be silly to use a find FindFirst in the same case. Better would be to restrict the original Query to return only that one record. And doing any of this with-out the use of indexes is also a hard thing.

You need to determine first what should the program accomplish, and what are the future goals of the program.

Go to the MSDN site and start looking by typing into the search box "optimizing code".

http://msdn.microsoft.com/default.asp?MSCOMTB=ICP_MSDN%20Online

Have fun!

by jimbb

A few quick and easy ones: if you don't intend to change data, make sure you make a snapshot in stead of a dynaset. In your SQL statements, try to avoid something like SELECT * FROM..., instead just select the fields you need: SELECT userID,firstname, lastname FROM... . And maybe you could create Queries that you then open, in stead of creating recordsets that do the same. Also, try pre-loading things you will be using but not changing. For example, pre-fill a list of customers, to avoid you have to do that again and again every time a certain form is used. It will slow down the start of your program, but speed up the usage.

Well, I'm just a part-time amateur, but these are some of the things I had to learn the hard way...;-)

Jim

by darryl severn

Are you reading from an Access report, or directly from the Access database? If you are pulling the data from a report, maybe try using direct access, or a pre-configured query.

by amwalsh

If the application is connecting to a database on another computer using ado or dao to set indexes, filters, etc., instead or an SQL statement with where clauses. You can see significant performance gains this way.

This discussion is closed to new replies.