473,890 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Variable column name

2 New Member
I have a database(Postgr eSQL) 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(colum n_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 4568
michaelb
534 Recognized Expert Contributor
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
7738
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
3735
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 MyVariant = 2 Then MsgBox "MyVariant also equals the value 2" 160 If MyVariant = "" Then HowManyCopies = 1 170 If Not IsNumeric(MyVariant) Then HowManyCopies = 1 MsgBox "OK. HowManyCopies has a value of " & CStr(HowManyCopies) 180 For i =...
3
2323
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: <th><a href=movie_details03.php?movie_id=$movie_id&coll_sort=\"review_date\">"Date
3
1197
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 it because of the space in the name column 1 or is it something else?
3
1068
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
2850
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. However, when I try to use the variable in the Where clause, either an error occurs or no rows are returned. Any thoughts greatly appreciated! I am using php-4.4.2 and MySQL-4.1.18-0 on Suse 9.1 Jerry
2
1162
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 something like this: Dept no_valid no_invalid a 4 1 b 7 2 c 3 5
1
1404
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 invalid column name or invalid descriptor index. i would be thank to u if u solve my problem. jump
0
3228
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 been searching for code for each part of the task separately and trying to piece together multiple macros, that do something similar, to what Iím trying to accomplish in my over all task, but Iím not having a lot of luck. So, hereís the entire task,...
0
9976
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
11215
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10908
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10451
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8008
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 presenter, Adolph Duprť who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6035
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4665
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4259
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3267
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.