zoukankan      html  css  js  c++  java
  • 得到Access数据库中所有表名

    public static List<string> GetShemaTables(string db)
            {           
                string path = Path.Combine(GlobalSettings.UnZipPath, db+".mdb");
                string ConnectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0}", path);
                //获取数据表
                OleDbConnection conn = new OleDbConnection();
                conn.ConnectionString = ConnectionString;
                try
                {  
                    conn.Open();
                    DataTable shemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
                    int n = shemaTable.Rows.Count;
                    List<string> tabs = new List<string>();
                    int m = shemaTable.Columns.IndexOf("TABLE_NAME");
                    for (int i = 0; i < n; i++)
                    {
                        DataRow m_DataRow = shemaTable.Rows[i];
                        tabs.Add(m_DataRow.ItemArray.GetValue(m).ToString());
                    }
                    return tabs;
                }
                catch (OleDbException ex)
                {
                    MessageBox.Show("指定的限制集无效: " + ex.Message);
                    return null;
                }
                finally
                {
                    conn.Close();
                    conn.Dispose();
                }
            }

  • 相关阅读:
    springboot+mybatis实现逆向工程
    关于cookie,session和token
    fiddler手机抓包配置
    js json按key值排序
    关于CSS和CSS3的布局小知识(干货)
    移动端手机上传图片处理
    nginx|gzip_static 安装
    Vue npm run serve linux 持久运行
    Web前端开发标准规范总结
    liunx启动node服务(nodejs+express+mysql+pm2)
  • 原文地址:https://www.cnblogs.com/mol1995/p/6042224.html
Copyright © 2011-2022 走看看