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();
                }
            }

  • 相关阅读:
    oracle列合并
    Java移位操作符
    angularjs 事件向上向下传播
    angularjs 路由 ngRoute tab切换
    angularjs 自定义服务
    angularjs 服务供应商
    angularjs 缓存 $q
    angularjs $location 服务
    angularjs $http 服务
    angularjs 自定义指令 directive
  • 原文地址:https://www.cnblogs.com/mol1995/p/6042224.html
Copyright © 2011-2022 走看看