KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
From the .NET environment can I get access to the full SQL string that is generated by a SqlCommand object? Note: The full SQL string shows up in Intellisense hover, in VisualStudio, while in debug mode. I'm willing to use reflection techniques if I must. I'm sure somebody here knows a way to get at it. Update 1 : I'm calling a stored procedure having parameters with cmd.CommandType = CommandType.StoredProcedure and am trying to acquire the full SQL generated and run. I wonder if the cmd. Prepare() method might not prove useful in this circumstance, if it might store the full string in a state field or something like that. Update 2: In light of answers below (and referenced) that indicate no complete SQL string is generated internally during preparation or execution, I did a bit of poking around using .NET Reflector. Even the internal connection classes seem to pass objects rather than boiling them down to strings, for example: internal abstract void AddPreparedCommand( SqlCommand cmd ); Declaring Type: System.Data.SqlClient.SqlInternalConnection Assembly: System.Data, Version=2.0.0.0 In general, thanks to everybody for the level of detail you got into to prove what can be done and show what's actually happening. Much appreciated. I like thorough explanations; they add surety and lend credence to the answers.
Tags (comma-separated)
Save Edits
Cancel