Masilo
Masilo

Reputation: 53

C# is there a way to check what kind of queries are sent to the database and what is the response?

I have a C# console App application using linq to send queries to the database and update records... There are like more than 40000(forty thousand records) to be updated in the database... Now I would like to develop something to keep track of the process as to what queries/requests are sent at a specific time and what is the response from the database. So I can be able to see if the query sent by the process/application is running slow or not...

I have tried to use System.Diagnostics but all I can get is how long the process is running or at what time the process has started running. I have thought of re-writing something to grab the query at the beginning and the end of the process but I somehow would like to know how many records are processed, how many are still pending and how many have failed or were successful in real time not at the end of the whole query or process.

At the moment what we do is, we practically login into the database and keep on executing a specific SQL query on the SSMS platform to keep track of how many records were successful/failed/still pending but I would like to automate the whole process so that management with no technical knowledge can be able to see whats happening. Any guidance or advice as to how I can achieve this?

Upvotes: 1

Views: 913

Answers (2)

3xGuy
3xGuy

Reputation: 2559

There are many tools that you can use, First like said in comments you can use Sql Server Profiler, another tool that I like to use is LinqPad with this tool you can see the results and the Sql that is sent. you can then modify the linq query and run again all inside the editor.

Upvotes: 2

MuKa
MuKa

Reputation: 165

A low-fi but quick to build solution. If you need to capture the performance of database queries which I believe gets called from your C# code, you can attempt at wrapping the query execution code block with start() and stop() functions of a stopwatch and consider logging the results into a DB table.

Upvotes: 0

Related Questions