I am creating an automated DB Query Execution Queue, which essentially means I am creating a Queue of SQL Queries, that are executed one by one.
Queries are executed using code similar to the following:
using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString))
{
cn.Open();
using (SqlCommand cmd = new SqlCommand("SP", cn))
{
cmd.CommandType = CommandType.StoredProcedure;
using (SqlDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{
}
}
}
}
What I would like to do is collect as much information as I can about the execution. How long it took. How many rows were affected.
Most importantly, if it FAILED, why it failed.
Really any sort of information I can get about the execution I want to be able to save.