Displaying results of an SQL query in ASP with unknown number of fields.

(ZippeeJJ this might be the GQ for you :slight_smile: )

I am fed up of being the only person at work direct access to our data, and therefore the go-to guy for all querys for which there isn’t already an asp report extant for it.
Therefore I aim to create an ASP page with one single input box (an sql query string) which does the obvious (outputs the results in a table)

I will then pester everyone to learn SQL!

It should be fairly safe (no edits, updates, stupidly intensive queries, or ability to crash/create havoc on the server)
Does anyone have any advice for this? Particularly the problem of creating a table when the number of fields (and name of fields) is unknown beforehand.

A pointer to the right sql commands would do… for instance a function or method of a recordset that returns number of fields, or some way of refering to the fields by number

Stupid brain. Stop missing out whole words from sentences.

" am fed up of being the only person at work with direct access to our data"

I googled it in the end. The following page seems to have my answers…

http://www.demarzo.net/archive/2004/08/19/running-ad-hoc-sql-queries-in-asp.aspx

Yep, that’s it.

Do your people have access to Query Analyzer or SQL Server 2005 Management Studio (depending on the version of SQL you’re storing the data in)? You can just show everyone how to run queries in that. I’ve been doing that lately with my non-technical employee lately and it’s worked well. You could give them SQL logins with tight permissions, too, that don’t include the ability to INSERT, UPDATE or DELETE.

The idea of having a “type your query here” page anywhere remotely near the Internet scares the shit out of me.