我有一个包含多个表的Access DB。我需要将它们全部转移到DataTable
数组。
这就是我所拥有的:
using (OleDbConnection conn = new OleDbConnection(connStr))
{
conn.Open();
tables = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
}
tables
是:public DataTable tables = null;
答案 0 :(得分:0)
解决方案是使用OleDbDataAdapter
和DataSet
:
public DataSet tables = new DataSet();
public OleDbDataAdapter adapter;
public BusLogic()
{
using (OleDbConnection conn = new OleDbConnection(connStr))
{
conn.Open();
adapter = new OleDbDataAdapter("SELECT * FROM City", conn);
adapter.Fill(tables, "Cities");
}
}