/// <summary> /// 获取指定表名的列名与描述注释 /// </summary> /// <param name="mdbFilePath"></param> /// <param name="tableName"></param> /// <returns></returns> public static Hashtable GetTableFieldsDisFromMdb(string mdbFilePath, string tableName) { Hashtable tableFields = new Hashtable(); try { ADOX.CatalogClass cat = new ADOX.CatalogClass(); string sAccessConnection = strConnRoot + mdbFilePath; ADODB.Connection cn = new ADODB.Connection(); cn.Open(sAccessConnection, null, null, -1); cat.ActiveConnection = cn; ADOX.Table tb = cat.Tables[tableName]; if (tb!=null) { foreach (ADOX.Column col in tb.Columns) { string colName = col.Name.ToString(); string colDis = ""; foreach (ADOX.Property pro in col.Properties) { if (pro.Name == "Description") { if (pro.Value != null) colDis = pro.Value.ToString(); break; } } tableFields.Add(colName, colDis); } } cat = null; cn.Close(); } catch (System.Exception ex) { return tableFields; } return tableFields; }
时间: 2024-10-03 20:25:33