Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Determine whether a query returns results or not (before running it)

Reply
Thread Tools

Determine whether a query returns results or not (before running it)

 
 
John Sway
Guest
Posts: n/a
 
      08-30-2003
I'm writing a web-based "Query analyser" tool for our company intranet. It
allows a user to type any SQL statement in a form, and execute it over the
Web.

The SQL can be a query that returns results (e.g: SELECT * FROM members) or
it can be a T-SQL (e.g: UPDATE/DELETE/INSERT).

What I want to know is, is there any way using either SQLCommand or DataSet
or any of the other ADO.NET classes to determine what kind of query it is,
BEFORE running it?

Then, if it is a T-SQL, I can just use the ExecuteNonQuery method, and I can
hide my datagrid that would contain the results. Or if it is a "SELECT"
query, I can populate a DataSet and show the results in a grid.

Do I have to manually parse out the SQL string to determine if it is SELECT
query? Or is there a more elegant way ?

Thanks!


 
Reply With Quote
 
 
 
 
William Ryan
Guest
Posts: n/a
 
      08-30-2003
All, SELECT, DELETE, UPdate, and Insert are SQL Statements (DML) and other
statements like Drop, Create, Alter are DDL. To determine if these (which I
think is what you want to do) being written, I'd use a Regex and just make a
determination on them. You could write a few different ways, but
essentially, you could make this determination pretty easy.

I have the regex's at work to do this if you are interested. Since you are
already going this far, you may want to test for a valid from, and if you
have a Group By statement, make sure you have an aggregate function listed.
Thanks to the kick a33 Regex engine .Net gives us, it's pretty
straightforward.

Cheers,

Bill
"John Sway" <(E-Mail Removed)> wrote in message
news:e3sSm$(E-Mail Removed)...
> I'm writing a web-based "Query analyser" tool for our company intranet. It
> allows a user to type any SQL statement in a form, and execute it over the
> Web.
>
> The SQL can be a query that returns results (e.g: SELECT * FROM members)

or
> it can be a T-SQL (e.g: UPDATE/DELETE/INSERT).
>
> What I want to know is, is there any way using either SQLCommand or

DataSet
> or any of the other ADO.NET classes to determine what kind of query it is,
> BEFORE running it?
>
> Then, if it is a T-SQL, I can just use the ExecuteNonQuery method, and I

can
> hide my datagrid that would contain the results. Or if it is a "SELECT"
> query, I can populate a DataSet and show the results in a grid.
>
> Do I have to manually parse out the SQL string to determine if it is

SELECT
> query? Or is there a more elegant way ?
>
> Thanks!
>
>



 
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
Can a Ruby program determine whether it's running on a 32-bit or64-bit system? Eric Promislow Ruby 5 09-04-2008 01:27 PM
Determine whether a thread is still running in Perl 5.8.8 with "interpreter threads" Samuel Perl Misc 2 05-10-2007 04:40 PM
Web UserControl - how to determine whether running in IDE Ben Fidge ASP .Net 1 06-22-2004 04:41 PM
How to determine whether a compiler supports wide character or not Ashabul Yeameen C Programming 1 09-16-2003 07:45 PM
how to determine whether a class instance in java ran to its completion or not google_java Java 1 07-08-2003 05:25 PM



Advertisments