Working with Access without the data control

Microsoft database Access is easy to use in combination with earlier versions of Visual Basic. Today (we speak 2005) we have several other possibilities. But they costs more in money, efforts and server-enviroment. Now we have SQL Server (version 7, 2k, 2k3, eventhe free 2k5 Express Edition).
We can easily connect from within Visual Basic to a MySQL database; even Oracle or Sybase is possible.

But Access is easy to use. And for most applications enough. Of course there are some disadventages on Access: it is not easy to repair a database. It's not for very big and intense used applications. But for a start it is easy.

In the next examples we see how you easily can connect, create, select to/from an access database from within Visual Basic.

This code is made for VB4. Therefor there are some commands that only exist in VB4 and NOT in VB3. But you can still use the same code. Just remember to change the following commands:
VB3VB4/5/6
Dim rs As Dynaset
Dim rs As Snapshot
Dim rs As Recordset
Set rs = db.CreateDynaset(..)
Set rs = db.CreateSnapShot(..)
Set rs = db.OpenRecordset(..,DBOpenDynaset)
Set rs = db.OpenRecordset(..,DBOpenSnapShot)
It will both work with Access 2.x and 7.x.

Topics