public Dictionary<string, DataTable> ReadFile(string strPath)
{
m_DbPath = string.Format(@"Data Source={0}", strPath);
try
{
using (SQLiteConnection connection = new SQLiteConnection(m_DbPath))
{
connection.Open();
DataSet dbTableName = new DataSet();
string tablenames = "select name from sqlite_master where type='table' order by name;";
SQLiteDataAdapter command = new SQLiteDataAdapter(tablenames, connection);
command.Fill(dbTableName);
foreach (DataRow myRow in dbTableName.Tables[0].Rows)
foreach (DataColumn myCol in dbTableName.Tables[0].Columns)
{
tablenames = "select * from " + myRow[myCol];
SQLiteDataAdapter commands = new SQLiteDataAdapter(tablenames, connection);
DataSet dbTable = new DataSet();
commands.Fill(dbTable);
grdViews.Add(myRow[myCol].ToString(),dbTable.Tables[0]);
}
}
}
catch
{
}
return grdViews;
}
C# 读取数据库文件到Dictionary
最新推荐文章于 2024-07-11 22:56:56 发布