
Help with book (Visual Basic 4 Databse How To)
I'm having trouble working through the examples in the book "Visual
Basic 4 Database How To" published by Waite Group Press.
The first few examples using the data control were fine but from
chapter 1.6 onwards where the examples use data access objects, I
can't seem to get any to run. I'm using VB4 16bit and Windows 95.
They bring up the following error when opening the database
"Class doesn't support OLE automation"
This is the offending code from chapter 1.6:
Private Sub Form_Load()
Dim dbName As String
Dim db As Database
On Error GoTo LoadError
' Get the database name and open the database.
dbname = "G:\VB\BIBLIO.MDB"
Set db = DBEngine.Workspaces(0).OpenDatabase(dbName)
' Open the recordset.
Set rs = db.OpenRecordset("Titles", dbOpenTable)
If rs.RecordCount > 0 Then
' We have at least one record, so display the values of the
first
' record in the recordset in the controls on the form.
DisplayRecord
Else
' An empty recordset, so display an explanation, then
terminate.
MsgBox "There are no records in the Titles table.", vbCritical
End
End If
Exit Sub
LoadError:
' An error was generated by Visual Basic or the Jet engine.
' Display the error message and terminate gracefully.
MsgBox Err.Description
End
End Sub
Also most of the projects use a function which reads a file called
VB4DBHT.INI and returns the fully qualified filename of biblio.mdb.
Well that would be fine if VB4DBHT.INI existed anywhere on my drives
or on the CD, but it doesn't!!!! I'm new to VB4 and would appreciate
some help from anyone who's tried these examples or who at least knows
what the hell is going on. I've gained a few grey hairs in the last
few days!!!!
Thanks