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

  • 相关阅读:
    LInux下几种定时器的比较和使用
    R中字符串操作
    GIS基本概念
    特征选择实践
    xcrun: error: invalid active developer path (/Applications/Xcode.app/Contents/Developer)解决办法
    mac os idea的快捷键
    python代码打包发布
    机器学习之聚类
    机器学习之决策树
    机器学习之逻辑回归
  • 原文地址:https://www.cnblogs.com/mol1995/p/6042224.html
Copyright © 2011-2022 走看看