Read user tables from access


/ Published in: VB.NET
Save to your folder(s)

This snippet reads all user tables from a Access Database


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.