Could you tell me how to cancel a query that takes a long time. For example select 1mln records. Like that:
Code: Select all
public string ExecQuery(string cmd, out DataTable dt)
{
dt = new DataTable();
string error = "";
try
{
OracleCommand command = new OracleCommand(cmd, sqlConnection);
using (OracleDataReader rdr = command.ExecuteReader())
{
using (rdr)
{
dt.Load((IDataReader)rdr); // THIS LINE TAKES OVER 1 MINUTE
}
}
}
catch (Exception ex)
{
error = ex.Message;
return error;
}
return error;
}
Right now I run this code in another thread. Object that calls this method needs connection to database to be created and has dispose method - where I disconnect from database. So I use 'using' to create this object.
Code: Select all
using (DatabaseProvider dp = new DatabaseProvider())
{
this.Result = dp.ExecQuery(this.Query, out this.Dt);
}
Could you tell me how to cancel this process ?