Re: Can VB8 read Access DBs?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Dick Monahan" <dick@xxxxxxxxxxxxxxx> wrote in message
news:e1uXZoLuGHA.2392@xxxxxxxxxxxxxxxxxxxxxxx
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.


Look for newsgroups with the words "dotnet",
"framework", or "vsnet" in their name.

For the news.microsoft.com news server try these:

news://msnews.microsoft.com/
microsoft.public.dotnet.languages.vb.data
microsoft.public.dotnet.framework.adonet
microsoft.public.dotnet.framework.interop
microsoft.public.dotnet.framework.windowsforms.controls
microsoft.public.dotnet.framework.windowsforms.databinding
</response>


.



Relevant Pages

  • Re: Reporting on nulls within a Database
    ... >>The master table in my Database is called tblApplication ... >dim tbl as DAO.tabledef ... >Dim fld as DAO.field ...
    (microsoft.public.access.modulesdaovba)
  • Re: Reporting on nulls within a Database
    ... >>The master table in my Database is called tblApplication ... >dim tbl as DAO.tabledef ... >Dim fld as DAO.field ...
    (microsoft.public.access.modulesdaovba)
  • Re: Reporting on nulls within a Database
    ... >>The master table in my Database is called tblApplication ... >dim tbl as DAO.tabledef ... >Dim fld as DAO.field ...
    (microsoft.public.access.modulesdaovba)
  • Re: Accessing multiple fields in report function
    ... The only other option would seem to be to open a recordset, ... The database already exists. ... >>> Dim Tbl As TableDef ... >>> For Each fld In Tbl.Fields ...
    (microsoft.public.access.modulesdaovba)
  • Re: Form fields to database and back?
    ... text information should be stored in the database in text ... redisplay it exactly as entered. ... $fld = htmlspecialchars_decode; ... To retrieve and redisplay I use: ...
    (comp.lang.php)