Posted By

dirkschoeters on 08/04/10


Tagged

tables user access


Versions (?)

Read user tables from access


 / Published in: VB.NET
 

This snippet reads all user tables from a Access Database

  1. Private Sub ReadUserTablesFromAccess(ByVal MDBPath As String)
  2.  
  3. Dim userTables As DataTable = Nothing
  4. Dim iLus As Integer
  5. Dim restrictions() As String = New String(3) {}
  6. Dim Con As OleDbConnection = New OleDbConnection()
  7.  
  8. If UCase(Strings.Right(MDBPath, 3)) = "MDB" Then
  9. Con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MDBPath & """"
  10. Else
  11. Con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & MDBPath & ";Persist Security Info=False;"
  12. End If
  13.  
  14. restrictions(3) = "Table"
  15.  
  16. Con.Open()
  17. userTables = Con.GetSchema("Tables", restrictions)
  18. Con.Close()
  19.  
  20. 'Clear table list first
  21. clb_TablesToCreate.Items.Clear()
  22.  
  23. For iLus = 0 To userTables.Rows.Count - 1
  24. clb_TablesToCreate.Items.Add(userTables.Rows(iLus)(2).ToString())
  25. Next
  26.  
  27. End Sub

Report this snippet  

You need to login to post a comment.