Parse SQL query in C#

  • Thread starter Thread starter Jimmy V
  • Start date Start date
J

Jimmy V

Hey all,

I am writing a query builder in C# 2005 and I want to parse the query
before I send it to the database. I remember being able to call a
Parse or TryParse method on a DMO object or something similar. It has
been a while since I have had to do this and forgot what object to
use. Anyone have any suggestions?

Thanks!
 
Jimmy,

You are targeting SQL Server, right? You can always SET NOEXEC ON on
the connection, pass the command (which will only be compiled, not executed)
and then see what comes back. If you don't get any errors, it is valid,
otherwise, it is invalid, and you can execute your query (just don't forget
to SET NOEXEC OFF before you try and execute the query).
 
Back
Top