Reputation: 6365
I have few oledb connections like this:
try
{
OleDbConnection Connection8;
using (Connection8 = new OleDbConnection("Provider=MSDAORA.1;Data Source=DATABASE:1521/orcl;Persist Security Info=True;Password=PASSWORD;User ID=USERNAME;"))
{
string sqlQuery = "select * from TABLE";
using (OleDbDataAdapter cmd = new OleDbDataAdapter(sqlQuery, Connection8))
{
Connection8.Open();
DataTable dt = new DataTable();
cmd.Fill(dt);
GridView5.DataSource = dt;
GridView5.DataBind();
v8 = 1;
Connection8.Close();
}
}
}
catch (Exception)
{
v8 = 0;
}
Some connections waiting so much, but I can't know which one.
How can I log or see query time for every connection? Any suggestion for that? Thank you.
Upvotes: 1
Views: 869
Reputation: 127563
I don't know if this will work because you are using a OleDbConnection
but one thing you may be able to do is in control panel open the "Odbc Administrator" (Be sure to check if you want 32 bit or 64 bit) there is a "Tracing" tab you can turn on, that gives you a log file of all ODBC requests that are processed.
But remember, like I said, because you are using a OleDbConnection
it may not log anything.
Upvotes: 0
Reputation: 26846
You can use Stopwatch:
var stopwatch = new Stopwatch();
DataTable dt = new DataTable();
stopwatch.Start();
Connection8.Open();
cmd.Fill(dt);
stopwatch.Stop();
var timeElapsed = stopwatch.ElapsedMilliseconds;
Notice here in sample I've shown time to open connection will be included in measured time. If you don't need it and want "pure" query execution time - then just change the order od lines where connection being opened and stopwatch started.
Upvotes: 3