Verifying SQL Syntax

  • Thread starter Thread starter Uzi Baruch
  • Start date Start date
U

Uzi Baruch

Hi!



Is there a way to verify an sql syntax befor running a command, i have a
query builder and i need to enable sql check on the user query befor running
it.



Thanks,

Uzi
 
Hi Uzi,

Not directly.
You might, however, add a nonsense condition to your query, such as WHERE
1=0 and execute it against database.
 
Thanks,

but i did found something - you can put SET NOEXEC ON befor the SQL
statement, and the command knows not to execute it agaisnt the data source
 
Hi Uzi,

Yes, but this is SQL server specific.
Now that I think about it, you might also try using IDbCommand.Prepare
method.
I didn't try it, but it should verify query on providers that support it.
 

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

Back
Top