Author Topic: VB6 DB Program  (Read 3665 times)

0 Members and 1 Guest are viewing this topic.

fielddog

  • Mosquito
  • Posts: 3
VB6 DB Program
« on: September 25, 2013, 07:23:47 AM »
I have written a VB6 program with MS Access DB connection
This is mostly for educational purpose; but the objective is to "catalog" hard copy
subdivision plats(or portions thereof)
Form1 is supposed to read/scroll through existing records while Form2 searches the DB.
It will read and write to the DB. However, I notice it seems to be skipping a large percentage
of the records in the DB. Also, it does not seem to reliably go through the DB in alphabetical order.
Have reset Form1, went into Access and resorted A-Z and saved, gone back into my program with same haphazard result.
I went into Properties and set Minimum Records to retrieve on startup  to 300
which is about twice the number of records presently.
I am using a ADODC control with Jet 4.0
Any input appreciated
« Last Edit: September 25, 2013, 07:38:43 AM by fielddog »

MickD

  • King Gator
  • Posts: 3636
  • (x-in)->[process]->(y-out) ... simples!
Re: VB6 DB Program
« Reply #1 on: September 25, 2013, 04:01:07 PM »
Hi fielddog,
first of all, sorting and saving the database won't do you any good. Even just for normal tables, all data is stored in memory where ever it gets put at the time, when you open a table to view it you are really only running a query on your data to build a table, that is the 'table' doesn't really exist but a query to build it when you open it does. I hope that makes sense.

Once you understand that you can start to manipulate the data how you like using SQL, for instance, if you want to load all records from a table in a particular order you grab a dataset (a custom table if you like) from the db running a query such as:

SELECT * FROM MyTable ORDER BY someField;

This will get all records from MyTable table and order them by the given field.

Once you have this dataset you can 'bind' it to your db grid view or whatever control you are using.

I'm not familiar with the control you are using but that's the general way it's done.

After this educational app is sorted I'd move on to VB.net or C# as soon as possible, VB6 is quite old and pretty much deprecated now and the .net world has many more and better controls and tools for working with databases.

Good luck.
"Programming is really just the mundane aspect of expressing a solution to a problem."
- John Carmack

"Short cuts make long delays,' argued Pippin.”
- J.R.R. Tolkien