473,320 Members | 2,177 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,320 software developers and data experts.

How to call the column which is selected in Combobox in SQL?

Gobindap
I want to call the column which is selected in combobox. Suppose, a table contains ID, name, A1, A2, A3, A4, A5 ......An. I want to return value from ID, name and a column which is selected from Combobox. (i.e. if A1 is selected in combobox then value from A1 should come if A2 is selected in combobox then value from A2 should come.

Is it possible? If possible then how can I do it? If impossible then how to solve such problems?
Feb 10 '13 #1

✓ answered by wizarddrummer

If you are referring to columns then what is stored in a combo box are the fields for whatever the query or record source of the combo box.
In your question you have ID, Name, A1 ... A5. If your table has 100 records then the combo box will have 100 rows from that table.
If you are able to select ID, Name, A1, A2 or A3, etc. as individual selections, in other words the drop down box displays the ID, Name, A1, etc. on a separate line then you don't have columns you have a field with many different types of data in it.

There would be no way to single out A1 or A2 or A3 if they are a column without creating a drop down box for each column based on a query.

4 2766
Rabbit
12,516 Expert Mod 8TB
You can do so by building a dynamic SQL string. That's all I can say without seeing your existing code.
Feb 10 '13 #2
If you are referring to columns then what is stored in a combo box are the fields for whatever the query or record source of the combo box.
In your question you have ID, Name, A1 ... A5. If your table has 100 records then the combo box will have 100 rows from that table.
If you are able to select ID, Name, A1, A2 or A3, etc. as individual selections, in other words the drop down box displays the ID, Name, A1, etc. on a separate line then you don't have columns you have a field with many different types of data in it.

There would be no way to single out A1 or A2 or A3 if they are a column without creating a drop down box for each column based on a query.
Feb 11 '13 #3
Thank you for your king support.

I think my problem is poorly described. I am making it clear now.

Suppose there are 10 columns in a table as: ID, name, A1, A2, A3, A4, A5, A6, A7 and A8. I want to return records from ID, name and one another column from among A1-A8. The next column I return is selected from dropdown list. Now general SQL to be written will be:
Expand|Select|Wrap|Line Numbers
  1. SELECT ID, name, <column to be selected from list> From ..... Where .....
For this I simply tried
Expand|Select|Wrap|Line Numbers
  1. String col = (String)comboBox.getSelectedItem();
Expand|Select|Wrap|Line Numbers
  1. SELECT ID, name, col FROM ..... WHERE .....
But it did not function correctly.
So, please help me to overcome my problem.
Feb 11 '13 #4
Rabbit
12,516 Expert Mod 8TB
I understand your question. The answer remains the same. You have to build a dynamic SQL string. And again, that's all I can say if you don't post the code you're using. So far, you've only posted one line of code and some generic SQL. The SQL, while code, is unlikely to be the exact line of code that you're actually using.

So unless you post the information that is asked for, there's not much I can do to help.
Feb 11 '13 #5

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

Similar topics

3
by: JAdrianB | last post by:
I'm trying to use a datagrid for data entry. I've created a couple of combo box columns using information from http://64.78.52.104/FAQ/WinForms/FAQ_c44c.asp#q480q That example basically sets...
3
by: MarkDu | last post by:
I want to have a datagrid, say 10 rows, and in one of the columns I want 7 of the rows to have plain text, and the other 3 rows to have a combobox (or linkbutton, etc). Is this even possible? I...
2
by: Vern | last post by:
I created a table in a dataset that contains multiple columns. I attached a combo box to that table. Now I'm doing something wrong with trying to retrieve the value of the third column of the...
0
by: SQLCE Server | last post by:
Not sure this is the right group to post to - but any help would be appreciated. I'm developing in VB.NET Compact Framework. I want to be able to pull data out of a SQLCE database on the mobile...
0
by: Michael C# | last post by:
I have found a few samples of using a combobox in a Datagrid on the Web (Windows Forms). While these examples work well for what they do, I need more functionality, and I'd like some advice on the...
2
by: wallermj | last post by:
I want to be able to compare the old combobox index to the newly selected combobox index in the SelectIndexChanged event. How can I do that? I know I could store the last selected value for the...
1
by: fariba123 | last post by:
i am developing an employee details website. i am creating a form to insert salary related information. i want that when the employee name is selected from the combobox, the designation and salary of...
2
by: genkidave | last post by:
Hi there, I have three combo boxes that I would like to have Disabled (grayed out???) and preselected to a particular selection until a radio button (YES) is clicked, thus enabling the combo...
1
by: neelsfer | last post by:
I have a combobox called "cmb_FindXC" that is filtered based on the mainform selection of a race. fields in combobox Distance - txtfield - column1 TotalLaps - numberfield - column2 Laprace...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.