toddbailey
Registered User.
- Local time
- Today, 13:16
- Joined
- Aug 26, 2011
- Messages
- 23
Hi All I wrote a simple import tool that imports 60K records into an Access data base. It basically reads a line from a text file, creates an insert statement, executes the insert and repeats.
If I open a connection 1 time and try to populate all 60K records using 1 connection, the process takes much longer than if I close and reopen the connection after every 1000 records. Any one have ideas why?
thanks
here is a small portion of the import process
System.Console.WriteLine(" Loading table");
long rowcnt = 0;
while ((text_line = freader.ReadLine()) != null)
{
rowcnt++
if (text_line.Trim().Length < 10) break; // look for a blank line then exit
string sqlstring = buildsqlstring(text_line,UseAccess);
ExecSqlString(sqlstring, conn, UseAccess);
if (rowcnt % 100 == 0)
{
System.Console.Write(rowcnt);
System.Console.Write(" rows processed. \r");
}
// for each 1,000 rows, close and reopen the connection to the database
if (rowcnt % 1000 == 0)
{
CloseDataBase(conn);
conn = OpenDataBase(UseAccess);
}
}
System.Console.WriteLine(" ");
System.Console.Write(rowcnt);
System.Console.WriteLine(" Data Rows Processed");
If I open a connection 1 time and try to populate all 60K records using 1 connection, the process takes much longer than if I close and reopen the connection after every 1000 records. Any one have ideas why?
thanks
here is a small portion of the import process
System.Console.WriteLine(" Loading table");
long rowcnt = 0;
while ((text_line = freader.ReadLine()) != null)
{
rowcnt++
if (text_line.Trim().Length < 10) break; // look for a blank line then exit
string sqlstring = buildsqlstring(text_line,UseAccess);
ExecSqlString(sqlstring, conn, UseAccess);
if (rowcnt % 100 == 0)
{
System.Console.Write(rowcnt);
System.Console.Write(" rows processed. \r");
}
// for each 1,000 rows, close and reopen the connection to the database
if (rowcnt % 1000 == 0)
{
CloseDataBase(conn);
conn = OpenDataBase(UseAccess);
}
}
System.Console.WriteLine(" ");
System.Console.Write(rowcnt);
System.Console.WriteLine(" Data Rows Processed");