Quote:
Originally Posted by imauser
I have a database (PostgreSQL) table(about 70k rows).I am developing an ASP
webpage and there is a list-box on it which contains the name of the
columns of that table. User selects the column name from that box and a
query is sent to the database. The data from that column should be
returned to the user.
Now the problem is that, I have seen the 'SELECT' statements with the
exact column name written in it.But in my case the column name is
variable. So, I am not able to understand how should I write such
query,where column name is like a parameter passed by the user. I am
working in .net for developing the webpage.
I have done the following, something similar may work for you:
-
query= "SELECT * FROM myTable WHERE idnum=" & request("id")
-
'...
-
'open the db and recordset
-
-
for each x in rs.fields
-
if request(x) <> "" then
-
rs(x) = request(x)
-
end if
-
next
-
-
rs.update
-
In the SELECT statement I just opened all of the columns. Then I went through each field and if a request(that field name) exists and has data, the data was set to that request variable.
Would something like that work for you?
Jared