Pezzzz
Pezzzz

Reputation: 748

Updating to Microsoft Access Object library 12.0, from DAO 3.6

I have some vb.net software using DAO 3.6, I am looking to upgrade it to use the MS access 12 library so I can run the software on windows 7 64bit.

Firstly am I correct in thinking that this library works with windows 7 64-bit and Access 2007?

My current Code:

Imports dao
Imports System.Runtime.InteropServices
Imports system.data


Public Sub DAOAccess()

    Dim dbe As dao.DBEngine
    Dim db As dao.Database
    Dim rs As dao.Recordset
    Dim ConnectionString As String
    dbe = New DBEngine

    Dim x, y As Integer

    ConnectionString = "J:\home\THC2WO\FieldMaster\DAO\FieldMaster.mdb"
    db = dbe.OpenDatabase(ConnectionString)
    rs = db.OpenRecordset("tabParameters")
    rs.Index = "ID_PAR"
    rs.MoveFirst()

    'frmFieldMaster.TextBox21.Text = ""
    For x = 0 To rs.RecordCount - 1
        For y = 0 To rs.Fields.Count - 1
            frmFieldMaster.TextBox21.Text = frmFieldMaster.TextBox21.Text & rs.Fields(y).Value & ", "
        Next
        rs.MoveNext()
        frmFieldMaster.TextBox21.Text = frmFieldMaster.TextBox21.Text & Chr(13) & Chr(10)
    Next

    rs.Close()
    db.Close()

I am struggling to find which imports I need at the start of the module to enable the new DBEngine. Also are there any big syntax changes when updating the reference?

If someone has some sample code including references that would help greatly.

Thanks for your help

Upvotes: 1

Views: 2442

Answers (2)

MarkJ
MarkJ

Reputation: 30398

Do consider migrating to ADO.Net instead.

If you do decide to migrate to ADO, you could look at some of the old advice for migrating from DAO to ADO in VB6. A lot of this advice will still be very relevant, as it relates to object models, differences in the database providers, etc. Here are some links

Upvotes: 2

HK1
HK1

Reputation: 12210

Try setting a reference to the COM object Microsoft Access 14.0 Object Library. Then you should be able to import Interop Access.

Imports Microsoft.Office.Interop.Access

However, I really recommend you consider moving to ADO.NET instead. It is quite different from DAO or ADO (classic) but it is also much more robust and flexible.

Upvotes: 3

Related Questions