Return to Snippet

Revision: 29761
at August 4, 2010 16:29 by dirkschoeters


Updated Code
Private Sub ReadUserTablesFromAccess(ByVal MDBPath As String)

        Dim userTables As DataTable = Nothing
        Dim iLus As Integer
        Dim restrictions() As String = New String(3) {}
        Dim Con As OleDbConnection = New OleDbConnection()

        If UCase(Strings.Right(MDBPath, 3)) = "MDB" Then
            Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MDBPath & """"
        Else
            Con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & MDBPath & ";Persist Security Info=False;"
        End If

        restrictions(3) = "Table"

        Con.Open()
        userTables = Con.GetSchema("Tables", restrictions)
        Con.Close()

        'Clear table list first
        clb_TablesToCreate.Items.Clear()

        For iLus = 0 To userTables.Rows.Count - 1
            clb_TablesToCreate.Items.Add(userTables.Rows(iLus)(2).ToString())
        Next

    End Sub

Revision: 29760
at August 4, 2010 16:12 by dirkschoeters


Updated Code
Private Sub ReadUserTablesFromAccess(ByVal MDBPath As String)

        Dim userTables As DataTable = Nothing
        Dim iLus As Integer
        Dim restrictions() As String = New String(3) {}
        Dim Con As OleDbConnection = New OleDbConnection()

        Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MDBPath & """"
        restrictions(3) = "Table"

        Con.Open()
        userTables = Con.GetSchema("Tables", restrictions)
        Con.Close()


        For iLus = 0 To userTables.Rows.Count - 1
            clb_TablesToCreate.Items.Add(userTables.Rows(iLus)(2).ToString())
        Next

    End Sub

Revision: 29759
at August 4, 2010 16:11 by dirkschoeters


Initial Code
Private Sub ReadUserTablesFromAccess(ByVal MDBPath As String)

        Dim userTables As DataTable = Nothing
        Dim iLus As Integer
        Dim restrictions() As String = New String(3) {}
        Dim Con As OleDbConnection = New OleDbConnection()

        Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MDBPath & """"
        restrictions(3) = "Table"

        Con.Open()
        userTables = Con.GetSchema("Tables", restrictions)
        Con.Close()

        'Maak tabel lijst eerst leeg
        clb_TablesToCreate.Items.Clear()


        For iLus = 0 To userTables.Rows.Count - 1
            clb_TablesToCreate.Items.Add(userTables.Rows(iLus)(2).ToString())
        Next

    End Sub

Initial URL

                                

Initial Description
This snippet reads all user tables from a Access Database

Initial Title
Read user tables from access

Initial Tags
user

Initial Language
VB.NET