问题
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, null, null, 0);
cat.ActiveConnection = conn;
ADOX.Table mhs = cat.Tables["MyTableName"];
string test = mhs.Columns["ColumnOfInterest"].Properties["Description"].Value.ToString();
回答1:
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")
来源:https://stackoverflow.com/questions/4936901/how-can-i-retrieve-column-descriptions-from-an-access-database-in-c