Adding ColumnName to a DropDownList

I have a problem which some wise and smart person would be able to help me with.

I currently have a table in an Access database which is as follows:
ColumnName - Type Example
Username -TEXT NakedProgrammer
Password -TEXT ******** (thenaked)
NewYork -YES/NO NO
LasVegas -YES/NO YES
Washington -YES/NO YES

The purpose is if you have lived in "NewYork" for example then you have a YES value. If you haven't then you get a NO value.

What i want is that when a person puts in his/her Username and Password combination, a DropDownList is populated with the ColumnTitles.

So using the above example data, if I log in using my username and password ("NakedProgrammer" and "thenaked"). I click the login button and the DropDownList should have the values of "LasVegas" and "Washington" in it, not "NewYork".

Does anybody know the best way to do this, is there a nice simple way


Using:
Microsoft Visual Studio 2005.
Windows XP
Using C++ to make a Website

Thanks,
The Naked Programmer





using Yes/No valued columns to add column name to dropdown textbox


Answer this question

Adding ColumnName to a DropDownList

  • skailey

    The fact you are running in to this problem now indicates a flaw in your database design. If this is one of the needs, the design should be so that it supports simple querying of this information.

    I think I would make if-statements for each column, and add the names of the columns where the value is yes to a string in that query, separated by semicolons. After getting that, you can string.Split() on the semicolons en use the resulting list for the dropdown.

  • Adding ColumnName to a DropDownList