how we get the columns name in listbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • veer
    New Member
    • Jul 2007
    • 198

    how we get the columns name in listbox

    Hi
    i made a program in which i select a database and the name of database comes in first textbox and in the combo box all the tables present in the selected database displayed in combo box
    now i want to make after this when i select any table name from combo box , then all the columns of selected table displayed in another combo box
    how can i will do this

    thanks in advance
    varinder
  • cloud255
    Recognized Expert Contributor
    • Jun 2008
    • 427

    #2
    have your table names be the value settings for the combobox entries.
    then insert that value into a select statement:

    Code:
    "select * from " +comboBox.selectedValue;
    run the query, put the results in a dataset.

    fill the second combo box:

    Code:
    for(int i = 0; i++; i< dataSet.Tables[0].Columns.Count)
    {
      //add item to the combobox
    }
    good luck

    Comment

    Working...