get column names from a table in an Access database using VB.NET

穿精又带淫゛_ 提交于 2019-11-29 17:43:26

You need to pass the name of the collection you are interested in to the GetSchema method. In the case of the columns collection, you also need to pass in an array of strings to filter the returned values.

Dim connectionString = csb2.ToString
Dim tableName = "Sales Reports"
Dim filterValues = {Nothing, Nothing, tableName, Nothing}

Using conn = New OleDbConnection(connectionString)
    conn.Open
    Dim columns = conn.GetSchema("Columns", filterValues)
    For Each row As DataRow In columns.Rows
        Console.WriteLine("{0,-20}{1}",row("column_name"),row("data_type"))
    Next
End Using

See here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!