Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / May 2008

Tip: Looking for answers? Try searching our database.

Parameterized Query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
xlar54 - 26 May 2008 16:28 GMT
Is there a way to see the exact SQL being generated from a
parameterized query?  I am using this technique but am getting some
strange SQL errors during execution and I would like to see the final
SQL that is being generated.
Lasse Vågsæther Karlsen - 26 May 2008 17:41 GMT
> Is there a way to see the exact SQL being generated from a
> parameterized query?  I am using this technique but am getting some
> strange SQL errors during execution and I would like to see the final
> SQL that is being generated.

A parameterized query doesn't generate any other sql, the query is sent
as-is to the database engine along with the parameter values, and the
database engine puts them all together.

In short, unless you're using a database that actually rewrites the sql
with the parameter values verbatim, you won't get what you're asking for.

Signature

Lasse Vågsæther Karlsen
mailto:lasse@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3

Marc Gravell - 27 May 2008 08:03 GMT
Just additional - most database enginers come with a trace/profiler
facility that can be used to see the final SQL statements. This is handy
when the code is auto-generated (LINQ-to-entities for example), but I
agree with the last reply: in this case it sounds like it will be sent
verbatim.

Marc
Alberto Poblacion - 27 May 2008 09:39 GMT
> Is there a way to see the exact SQL being generated from a
> parameterized query?  I am using this technique but am getting some
> strange SQL errors during execution and I would like to see the final
> SQL that is being generated.

If you are using Microsoft SQL Server, it includes a tool "SQL Server
Profiler". If you run it, it will let you capture all the SQL that the
server is receiving from the client. You may find it useful to examine the
calls that the client is sending to the server. As others replied before,
you will find out that the parameterized query is sent "as is", along with
the values of the parameters.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.