小编use*_*331的帖子

从 C# 读取 Access 2007 (accdb) 文件的性能非常慢

我正在使用 C# 在 Visual Studio 2008 上编写一个应用程序。应用程序从 access 文件读取数据,然后生成 txt 文件。我正在使用一个包含 1.000.000 条记录且大小接近 1GB 的 mdb 文件进行一些测试。代码如下,整个过程需要 8 - 10 分钟才能完成。

var connStr =  string.Format("Provider =Microsoft.Jet.OLEDB.4.0; Data Source={0};Persist Security Info=False", this.dbPath);

using (var conn = new OleDbConnection(connStr))
{
            using (var command = conn.CreateCommand())
            {   

                command.CommandText = "SELECT * from Registros r, FOIDS f where r.TICKET = f.TICKET";
                command.CommandType = System.Data.CommandType.Text;
                conn.Open();

                int i = 0;
                string ticket = string.Empty;

                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                         i++;

                            if …
Run Code Online (Sandbox Code Playgroud)

c# oledb performance ms-access ms-office

5
推荐指数
1
解决办法
3931
查看次数

标签 统计

c# ×1

ms-access ×1

ms-office ×1

oledb ×1

performance ×1