Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Populate Combobox from Access Database

combobox

  • Please log in to reply
1 reply to this topic

#1 Aelustelin

Aelustelin

    CC Lurker

  • Just Joined
  • Pip
  • 2 posts

Posted 05 September 2011 - 01:28 PM

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.
  • 0

#2 Nishantstech

Nishantstech

    CC Lurker

  • New Member
  • Pip
  • 7 posts

Posted 06 September 2011 - 01:17 AM

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





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download