ive searched for the archive but cant find a suitable entry. sorry if exists.
im using vs2008, .NET 3.5, MS-SQL2008
My Code is simple;
SqlConnection CONN=new SqlConnection(SomeConnectionString);
CONN.Open();
SqlCommand cmd = CONN.CreateCommand();
cmd.CommandText="SELECT FIELD1,FIELD2,FIELD3 from table1";
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
so DataTable dt is ready to use.
But i want to make the query stoppable by user, coz it may last too much long to wait. so user will stop the query, change parameters and requery.
Also i want to show a stopwatch for query time, during query execution.
As expected, i cant do those in the same thread of sql query.
What should be the best and simplest threading approach for above code? can someone reply a piece of code for that? note that; DataTable dt must be available for the main thread at the end.
thanks in advance