|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Convert DAO from VB6 to VB8?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. Dick,
Noboby is using the name VB8 as nobody is using NT5 or NT51 what is your purpose with this message, to get help or to start a discussion? Try to make a clear message as readable for those you ask help from as possible. As well can you when you have troubles to look at true dotNet code, although this is converted, is seldom somebody in these newsgroups intrested to take old converted code. Here a sample of that http://www.vb-tips.com/dbpages.aspx?ID=26f91edd-044c-4e71-8c6c-e9d7983c1e05 I hope this helps, Cor Show quoteHide quote "Dick Monahan" <d***@dickmonahan.com> schreef in bericht news:Or0MoqbuGHA.2224@TK2MSFTNGP06.phx.gbl... >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. > > > > I suspect in this case, you are having a problem with the DAO reference.
If I recall correctly, DAO was dropped from MDAC around version 2.6. You might need to find an older copy of MDAC and use that to install DAO if you want to continue using that for your data access API. If you are migrating an application to .Net, you should consider migrating your data access code from DAO to Ado.Net. There are no automatic upgrade paths that I know of from DAO to ADO.Net. Jim Wooley http://devauthority.com/blogs/jwooley/default.aspx Show quoteHide quote > 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. >
Update problem ADO vbnet 2005
Remoting - Some methods hang on certain setups. Getting database fields (rows) to appear as columns in datagrid Showing a form from within a thread Hyperlink and Label Update a structure when another structure changes Wildcards Random Overwriting a file Databinding datagridview to textbox |
|||||||||||||||||||||||