Jump to content

Populate Combobox from Access Database

- - - - -

  • Please log in to reply
1 reply to this topic

#1
Aelustelin

Aelustelin

    Newbie

  • Members
  • Pip
  • 2 posts
Here is what I have so far

   sql = "SELECT PATIENTS_FName + ' ' + PATIENTS_LName AS FullName FROM PATIENTS";

            OleDbCommand dbCom = new OleDbCommand(sql, dbConn);

            dbCom.ExecuteNonQuery();

            DataSet names = new DataSet();

            OleDbDataAdapter dbAda = new OleDbDataAdapter(dbCom);

            dbAda.Fill(names, "ImportTable");


            comboBox1.DataSource = names.DefaultViewManager;

            comboBox1.ValueMember = "FullName";

            comboBox1.DisplayMember = "FullName";

I get an error pointing to this line:

comboBox1.ValueMember = "FullName";


Saying ArgumentException was Unhandled. Cannot Bind to new display member. Parameter name: newDisplayMember.

Any help would be appreciated. I am doing this for fun and am completely stumped by this problem.

#2
Nishantstech

Nishantstech

    Newbie

  • Members
  • Pip
  • 7 posts
Kindly make sure that "FullName" column is there inside the table from where you are quering the data.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users