D
Dick Monahan
I have a little VB6 program that dumps the schema of an Access 97 database.
The following lines of code are relevant.
Private m_wsDb As DAO.Workspace
Private m_db As DAO.Database
Set m_wsDb = DBEngine.CreateWorkspace("MainWS", "admin", vbNullString)
Set m_db = m_wsDb.OpenDatabase(m_zDbFilePath, False, False, "")
Dim tdf As TableDef
Dim fld As DAO.Field
For Each tdf In m_db.TableDefs
On Error GoTo Form_Activate_Err_Tabledef
Debug.Print "Table "; tdf.Name; " ("; tdf.RecordCount; "records )."
On Error GoTo Form_Activate_Err_Field
For Each fld In tdf.Fields
Debug.Print " Field "; fld.Name; " ("; GetFieldType(fld.Type); ": ";
fld.Size; ")."
Next fld
Next tdf
I converted the program to VB8 (.NET if you prefer). As far as I can see,
the only relevant lines that it changed are these two.
m_wsDb = DAODBEngine_definst.CreateWorkspace("MainWS", "admin",
vbNullString)
Dim tdf As DAO.TableDef
When I try to read the Access 97 database with the VB8 program, it opens the
workspace and the database, but when I try to fetch a field, I get:
A first chance exception of type
'System.Runtime.InteropServices.COMException' occurred in
ExportSchema.exe
And Err = 3219 (Invalid operation.).
I also have the same database in Access 2000 and 2003 formats. When I try to
read either of them with the VB8 program, I get:
A first chance exception of type
'System.Runtime.InteropServices.COMException' occurred in
ExportSchema.exe
And Err = 3343 (Unrecognized database format '<path>'.
What have I missed in converting VB6 -> VB8?
Dick.
The following lines of code are relevant.
Private m_wsDb As DAO.Workspace
Private m_db As DAO.Database
Set m_wsDb = DBEngine.CreateWorkspace("MainWS", "admin", vbNullString)
Set m_db = m_wsDb.OpenDatabase(m_zDbFilePath, False, False, "")
Dim tdf As TableDef
Dim fld As DAO.Field
For Each tdf In m_db.TableDefs
On Error GoTo Form_Activate_Err_Tabledef
Debug.Print "Table "; tdf.Name; " ("; tdf.RecordCount; "records )."
On Error GoTo Form_Activate_Err_Field
For Each fld In tdf.Fields
Debug.Print " Field "; fld.Name; " ("; GetFieldType(fld.Type); ": ";
fld.Size; ")."
Next fld
Next tdf
I converted the program to VB8 (.NET if you prefer). As far as I can see,
the only relevant lines that it changed are these two.
m_wsDb = DAODBEngine_definst.CreateWorkspace("MainWS", "admin",
vbNullString)
Dim tdf As DAO.TableDef
When I try to read the Access 97 database with the VB8 program, it opens the
workspace and the database, but when I try to fetch a field, I get:
A first chance exception of type
'System.Runtime.InteropServices.COMException' occurred in
ExportSchema.exe
And Err = 3219 (Invalid operation.).
I also have the same database in Access 2000 and 2003 formats. When I try to
read either of them with the VB8 program, I get:
A first chance exception of type
'System.Runtime.InteropServices.COMException' occurred in
ExportSchema.exe
And Err = 3343 (Unrecognized database format '<path>'.
What have I missed in converting VB6 -> VB8?
Dick.