473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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....

?column?
---------------
column_name
column_name
column_name
column_name
column_name
..........
..........
column_name


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

thanx
Apr 24 '07 #1
1 4540
michaelb
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

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

Similar topics

3
by: Nelson Broat | last post by:
In jsp land you can have the following: <% String name = "Nelson"; %> Hi, my name is <%= name %>. Such that, in your browser you see:
20
by: MLH | last post by:
120 MyString = "How many copies of each letter do you need?" 150 MyVariant = InputBox(MyString, "How Many?", "3") If MyVariant = "2" Then MsgBox "MyVariant equals the string '2'" If...
3
by: universalbitmapper | last post by:
Hi, This exercise (From PAM525Web Development) asks me to display a table of reviews, then sort the reviews depending on which column heading is clicked. I can't find how to write this line:...
3
by: sparks | last post by:
tempname = FindSpaces(rs!) this works fine but if I try to pass a variable value to it For i = 1 To 3 Step 2 tempname = FindSpaces(rs!) why can't the variable i just be used in this way? Is...
3
by: Mrozu | last post by:
Hi How can I include in name of my variable value of other variable? I have following code: For x = 0 To 10 Dim column As New DataGridTextBoxColumn column.MappingName = magazyny(x)
8
by: Jerry | last post by:
I am a MySQL and PHP newbie. I am having trouble getting the $w variable in my code below passed to mysql. When I use the value of $w directly in the Where clause, the correct rows are returned....
2
by: davey.phillips | last post by:
I have a datagrid within a datagrid which is filled with data from an SQL Server db. Each inner datagrid is populated by an sql statement which contains a variable column name. Output looks...
1
by: jump | last post by:
hi ! i m using the java program and i want to access the variable column from the ms sql server data base . when i try to access the particular value as"select * from where =; i get the error as...
0
by: Taxman | last post by:
Windows XP, MS Office Excel 2003 If the tasks, I’m trying accomplish have been addressed previously (separately or in combination). Please, provide the links or keyword search to find them. I’ve...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.