tables list in access
-
Try this, this is working on SQL Server. Create Sample That Lists Tables in a Database The following sample lists tables in the SQL Server Northwind database. OleDbSchemaGuid.Tables returns those tables (including views) that are accessible to a given log on. If you specify an Object array of {Nothing, Nothing, Nothing, "TABLE"}, you filter to include only a TABLE_TYPE of TABLE. You then list the table name (TABLE_NAME) of each row in the returned schema table. 1. Start Visual Studio .NET. 2. Create a new Visual Basic Console Application project. Module1.vb is added to the project by default. 3. Open the Code window for Module1. Paste the following code into the top of the Code window, above the Module declaration: Imports System.Data Imports System.Data.OleDb 4. In the Code window, paste the following code into the Sub Main procedure. Note You must change User ID and password = to the correct values before you run this code. Make sure that User ID has the appropriate permissions to perform this operation on the database. Dim cn As New OleDbConnection() Dim schemaTable As DataTable Dim i As Integer 'Connect to the Northwind database in SQL Server. 'Be sure to use an account that has permission to list tables. cn.ConnectionString = "Provider=SQLOLEDB;Data Source=server;User ID=;Password=;Initial Catalog=Northwind" cn.Open() 'Retrieve schema information about tables. 'Because tables include tables, views, and other objects, 'restrict to just TABLE in the Object array of restrictions. schemaTable = cn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, _ New Object() {Nothing, Nothing, Nothing, "TABLE"}) 'List the table name from each row in the schema table. For i = 0 To schemaTable.Rows.Count - 1 Console.WriteLine(schemaTable.Rows(i)!TABLE_NAME.ToString) Next i 'Explicitly close - don't wait on garbage collection. cn.Close() 'Pause Console.ReadLine()****