Dim Company As OleDb.OleDbConnection
Company = New OleDb.OleDbConnection
Company.ConnectionString = “Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\.Net Project\Accounting Pack\AccountingPack.accdb”
Company.Open()
Dim cmd As New OleDb.OleDbCommand(“Select * from ” & tbl, Company)
Dim columns As String = “Columns”
Dim dt As DataTable = Company.GetSchema(columns)
For Each row As DataRow In dt.Rows
console.writeline(row.Item(“COLUMN_NAME”).ToString)
Next
Company.Close()
End Sub
I
First we create connection object, Company and a connection string. Then we need a OleDb.OleDbCommand object to set database to point a particular table, so that we created the cmd object and used it for query the input table.
II
In the next stage we created a column string in order to point Columns in the table. Using Getschema() method of connection object Company we stored each and every column name in the connection to the table variable dt.
III
In the final step we can access all rows from the dt which contain column names from table dt using COLUMN_NAME field.
Here is the video tutorial of how you can access and add column names to the console.