Parse SQL query in C#

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!
 
N

Nicholas Paldino [.NET/C# MVP]

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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top