S
Sek
Hi Folks,
I am using OLEDB to log real-time data to a local mdb file from my C#
app.
I will be generating a new .mdb file every 1 hour on the local machine
and continue to log the data into the new file. So, the connection
pooling is of little help to me.
I use QueryPerformanceCounter to calculate the time taken by method
invocations.I want to reduce the time taken by the calls to DB.
Following is the code to create DB, Table, Open and Close connection.
*******************************************************
// Create DB
myTimer.Start();
string dbStr = connecStr + folderPath + "\\" + fileName;
ADOX.CatalogClass cat = new ADOX.CatalogClass();
cat.Create(dbStr);
cat = null;
myTimer.Stop();
log(myTimer.Duration(1));
odb = new OleDbConnection(dbStr);
// Construct CreateTable command
StringBuilder crtTableCmd = new StringBuilder();
......
myTimer.Start();
odb.Open();
// Create Table
OleDbCommand odc = new OleDbCommand(crtTableCmd.ToString(),odb);
odc.ExecuteNonQuery();
myTimer.Stop();
log(myTimer.Duration(1));
dap = new OleDbDataAdapter();
dap.SelectCommand = new OleDbCommand("SELECT * FROM Readings",odb);
ds.Reset();
myTimer.Start();
dap.Fill(ds,"Readings");
myTimer.Stop();
log(myTimer.Duration(1));
myTimer.Start();
odb.Close();
myTimer.Stop();
log(myTimer.Duration(1));
*****************************************************
Following are my questions:
1) The time taken by ADOX.CatalogClass.Create method is varying
rampantly from 25ms to 200ms. Why is this so?
2) OleDbConnection.Open takes around 5ms and OleDbConnection.Close
takes around 10ms. Why does close take more time than open? Is there
any way to reduce the time consumption further.
3) OleDbDataAdapter.Update takes around 20ms. Is there any way to
reduce it further?
TIA.
Sek
I am using OLEDB to log real-time data to a local mdb file from my C#
app.
I will be generating a new .mdb file every 1 hour on the local machine
and continue to log the data into the new file. So, the connection
pooling is of little help to me.
I use QueryPerformanceCounter to calculate the time taken by method
invocations.I want to reduce the time taken by the calls to DB.
Following is the code to create DB, Table, Open and Close connection.
*******************************************************
// Create DB
myTimer.Start();
string dbStr = connecStr + folderPath + "\\" + fileName;
ADOX.CatalogClass cat = new ADOX.CatalogClass();
cat.Create(dbStr);
cat = null;
myTimer.Stop();
log(myTimer.Duration(1));
odb = new OleDbConnection(dbStr);
// Construct CreateTable command
StringBuilder crtTableCmd = new StringBuilder();
......
myTimer.Start();
odb.Open();
// Create Table
OleDbCommand odc = new OleDbCommand(crtTableCmd.ToString(),odb);
odc.ExecuteNonQuery();
myTimer.Stop();
log(myTimer.Duration(1));
dap = new OleDbDataAdapter();
dap.SelectCommand = new OleDbCommand("SELECT * FROM Readings",odb);
ds.Reset();
myTimer.Start();
dap.Fill(ds,"Readings");
myTimer.Stop();
log(myTimer.Duration(1));
myTimer.Start();
odb.Close();
myTimer.Stop();
log(myTimer.Duration(1));
*****************************************************
Following are my questions:
1) The time taken by ADOX.CatalogClass.Create method is varying
rampantly from 25ms to 200ms. Why is this so?
2) OleDbConnection.Open takes around 5ms and OleDbConnection.Close
takes around 10ms. Why does close take more time than open? Is there
any way to reduce the time consumption further.
3) OleDbDataAdapter.Update takes around 20ms. Is there any way to
reduce it further?
TIA.
Sek