Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > validate query before execution

Reply
Thread Tools

validate query before execution

 
 
Chuck Foster
Guest
Posts: n/a
 
      05-24-2006
Does anyone know a way to check if an inline SQL statement is valid before
executing it? something like....
sql = "select * from tblOne";
sql.connection = sqlconnection1;
if (sql.IsValid())
{
//do something
}

Thanks in advance for any advice!

Chuck Foster


 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      05-24-2006
"Chuck Foster" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Does anyone know a way to check if an inline SQL statement is valid before
> executing it? something like....
> sql = "select * from tblOne";
> sql.connection = sqlconnection1;
> if (sql.IsValid())
> {
> //do something
> }


Why not just execute the query and find out if it's valid? One of the first
things SQL Server will do is validate the syntax of the query.

Is this query coming from user input (dynamic SQL)?

John


 
Reply With Quote
 
 
 
 
Will Asrari
Guest
Posts: n/a
 
      05-24-2006
I'm confused. I can't see where or why an end-user (I'm assuming)
would be entering raw SQL statements to be processed. If you are
wanting to validate a SQL statement that you are going to write simply
use Query Analyzer to see if you get any results.

SELECT * FROM _tbl WHERE This = "that"

Then change from static to dynamic once you know that the query works.

string _sql = "SELECT * FROM _tbl WHERE This = '" + var + "';

- Will

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
private data stashed in local/global execution context of PyEval_EvalCode disappears down the execution stack sndive@gmail.com Python 9 11-14-2007 10:31 PM
Validate before JScript Peter ASP .Net 9 01-26-2006 07:02 PM
Ways to validate form before submitting Wysiwyg ASP .Net 4 01-26-2005 06:40 PM
validate data before dropping into sql table luna ASP .Net 1 02-13-2004 04:01 PM
Validate Changed Data Before Submitting Johnny ASP .Net 1 11-25-2003 07:40 PM



Advertisments