Connecting Microsoft Access via Inventor iLogic

<?xml encoding=”UTF-8″>by Chandra shekar Gopal

If you want to connect Microsoft Access Database through Inventor iLogic, a data connectivity driver called “2007 Office System Driver : Data Connectivity Components” is required to install in system. It can be downloaded from this link(Download Employeeinfo)

After successful installation of driver,the following iLogic code can be used to access Microsoft Access database in Inventor 2017

AddReference "System.Data"
AddReference "System.Core"
AddReference "System.Xml"

Imports System.Data.OleDb
Imports System.Data
Imports System.Xml

Sub Main()

    Dim Table_ As String = "EmployeeInfo"
    Dim query As String = "SELECT * FROM " & Table_

    Dim MDBConnString_ As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Temp\EmployeeInfo.accdb;Persist Security Info=False;"

    Dim ds As New DataSet
    Dim cnn As OleDbConnection = New OleDbConnection(MDBConnString_)

    cnn.Open()

    Dim cmd As New OleDbCommand(query, cnn)
    Dim da As New OleDbDataAdapter(cmd)

    da.Fill(ds, Table_)

    cnn.Close()

    Dim t1 As DataTable = ds.Tables(Table_)
    Dim row As DataRow
    Dim Item(2) As String

    For Each row In t1.Rows
        MessageBox.Show("EID : " & row(0) & " and Employee Name : " & row(1))
    Next

End Sub

To demonstrate code, a sample database (EmployeeInfo.accdb) is created and that would like as shown below.

Sample_Database

Sample database can be downloaded from here. After downloading database to desire location, path of database should be updated in the above iLogic code.

Result:

1
2
3
4
5
6


Comments

3 responses to “Connecting Microsoft Access via Inventor iLogic”

  1. It’s a helpful tutorial. Thanks! Check here how to active MS Office [url=https://officeinstallonline.com/ms-office-support/%5DMS Office [/url]

  2. Willem Jaspers Avatar
    Willem Jaspers

    Yes this is a nice tutorial but how do you do the same as this but then list all the TABELES in the accdb File
    Like if you have EmployeeInfo01 , EmployeeInfo03 ,ETC

  3. Hi William,
    Your query has been answered in the below forum discussion link.
    https://forums.autodesk.com/t5/inventor-customization/need-help-ilogic-microsoft-access-tables-to-list/m-p/9031687/highlight/false#M101382
    Thanks and regards,
    Chandra shekar G

Leave a Reply