我正在使用OleDbDataAdapter类从Access(.mdb)文件中获取数据。OleDbDataAdapter填充方法性能不佳
OleDbConnection con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="+Environment.CurrentDirectory+"\\Data.mdb;Jet OLEDB:Database Password=pass");
OleDbCommand com = new OleDbCommand(query, con);
DataTable dt = new DataTable();
con.Open();
OleDbDataAdapter oda = new OleDbDataAdapter(com);
oda.Fill(dt);
oda.Dispose();
com.Parameters.Clear();
con.Close();
return dt;
问题是,通过调试我发现,oda.Fill(dt)
需要很长时间才能执行。 (大约10秒)
我在数据库中有50,000条记录,我只需要检索1行。
请帮忙。先谢谢你。
你的“查询”是什么?你的桌子有索引或什么的? –
如果您使用'DataReader',则只能读取第一行,而不必处理其他不需要的记录。 – Hambone
这是我的查询:'select_mname,received_date,measure_date,height,weight,calory,pbf_rate,std_weight,member_data where id_number = 1000' –