Resolved How to view sql command execution with Stored Procedure ?

Samuel David

Member
Joined
Nov 29, 2022
Messages
9
Programming Experience
Beginner
Hello Everyone,

I have below block of code.

StoredProcedure with Parameters:
private TData ExecuteReturnData<TData>(string procName, Func<IDataReader, TData> translator, SqlConnection sqlCon, params SqlParameter[] parameters)
{
using var sqlCmd = CreateCommand(procName, sqlCon, parameters);
sqlCmd.CommandTimeout=120;
using var reader = sqlCmd.ExecuteReader();
var elems = translator(reader);
return elems
}


Here I want to see the complete sql command execution with params in sql server code block. How can i check that here(C#)

Thanks,
Sam
 
Solution
What does this actually mean?

Show us what you expect the output of the exercise to be like
I was intending to say something similar. Are you saying that you want to see the SQL code with the parameter values substituted for the place holders? If so then you definitely can't because that never exists in your app. If you don't mean that then I'm not sure what you do mean. Whatever it is, it seems likely that you'd need to use SQL Profiler or a similar tool that is part of the database.
I don't think you can from within C# nor with the debugger. You'll need to look at it from the server side.
 
What does this actually mean?

Show us what you expect the output of the exercise to be like
I was intending to say something similar. Are you saying that you want to see the SQL code with the parameter values substituted for the place holders? If so then you definitely can't because that never exists in your app. If you don't mean that then I'm not sure what you do mean. Whatever it is, it seems likely that you'd need to use SQL Profiler or a similar tool that is part of the database.
 
Solution

Latest posts

Back
Top Bottom