469,913 Members | 2,064 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,913 developers. It's quick & easy.

Variable column name

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 tried to use a prepare statement....

PREPARE statement(text) AS SELECT $1 FROM table_name;
EXECUTE statement(column_name);

this returns....


I can't figure out the problem in this .........if there is another solution to this plz suggest.......

Apr 24 '07 #1
1 4100
534 Expert 512MB
Although this manual does not say it explicitely, I don't think you can pass a table name, or a column name as an argument to prepared statement.

Try to run the plain SQL query instead.
Apr 25 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by universalbitmapper | last post: by
3 posts views Thread by Mrozu | last post: by
8 posts views Thread by Jerry | last post: by
2 posts views Thread by davey.phillips | last post: by
1 post views Thread by jump | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.