博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
c#获取access字段的说明描述
阅读量:7199 次
发布时间:2019-06-29

本文共 1581 字,大约阅读时间需要 5 分钟。

hot3.png

  ///         /// 获取指定表名的列名与描述注释        ///         /// 
        /// 
        /// 
  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;        }

转载于:https://my.oschina.net/cthulhu/blog/366548

你可能感兴趣的文章