Skip to content

How to show field from access in comboBox

ghasem deh

ghasem deh

Asked Aug 11, 2014, 12:09 AM EDT3 answers
Share
LinkedInX
hi guy's
-----------------------------
my project have a database (access) with 3 table ...
how to show field from database (ID or Name of table 1)  in comboBox ?
then insert in table B ...!
thank's

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • +1
    insert into tableB (id, name) select id, name from table 1
    +1
  • +1
    your code will populate combo box rite.

    but you've to write code when user select value in combo box it should be inserted into new table.

    something like this shall work for you:

    da.newRow(combo1.value);
    da.insert();

    i may be wrong syntactically but algorithm is right
    +1
  • ghasem deh
    0
    tanks to answer ...
    this code is OK


    DataTable table = new DataTable();
                    string sql = "Select New from Album";
                    con.Open();
                    OleDbDataAdapter da = new OleDbDataAdapter(sql, con);
                    da.Fill(table);
                    table.Rows.Add(" ");
                    comboBox1.DataSource = table;
                    comboBox1.DisplayMember = "New";
                    comboBox1.ValueMember = "New";
                    comboBox1.SelectedValue = " ";
    0