I am writing an application on Visual Studio 2008 with C#. The application reads data from an access file and then generates a txt file. I was doing some tests with a mdb file with 1.000.000 records and almost 1GB size. The code is like this and the overall process was taking between 8 - 10 minutes to complete.
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 (!reader.IsDBNull(reader.GetOrdinal("r.TICKET")))
{
ticket=reader.GetString(reader.GetOrdinal("r.TICKET"));
// Some process
}
}
}
}
}
}
Today I received an accdb file (Access 2007), so I've changed my connection string to this one:
connStr = string.Format(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Persist Security Info=False", this.dbPath);
But after that change, reading the new file is taking about 4-5 seconds per record !!! So, my overall process would take a lot of DAYS to complete! I've tried converting the accdb file to an old mdb file and after that reading again with the previous connection string, but the problem remains. I think is a problem with the database itself but I don't know what to do, in internet i didn't found any information with this kind of problem.
Any ideas? Suggestions?
OleDbDataAdapter.Fill(DataTable)
, and then processing that in-memory set of rows?? Does it run any faster? It's hard to really say without access to a copy of a at least a dummy database with the same behavior. – Kidnap