开发者

How can I retrieve column descriptions from an access database in C#?

I am trying to retrieve column descriptions for MS Access columns using C# (the text entered by the user in the table designer to describe the purpose of a column). How does one go about this? I thought maybe ExtendedProperties in the Column would hold this but when I get a DataTable through an OleDbConnection and loop through the columns, ExtendedProperties always has a count of 0.

EDIT: Thanks, Remou, that did the trick. Below is a quick test in C#

            Catalog cat = new ADOX.CatalogClass();
            ADODB.Connection conn = new ADODB.Connection();
            conn.Open(_connectionString, 开发者_如何学Pythonnull, null, 0);
            cat.ActiveConnection = conn;
            ADOX.Table mhs = cat.Tables["MyTableName"];
            string test = mhs.Columns["ColumnOfInterest"].Properties["Description"].Value.ToString();


Using an ADOX catalogue, you can look at the field property Description, in VBA:

catDB.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & CurrentProject.FullName

Set tbl = catDB.Tables("New")

Set fld = tbl.Columns("Test")
Debug.Print fld.Properties("Description")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜