Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Populating a combobox with values from SQL database

Posted on 2010-11-14
1
Medium Priority
?
291 Views
Last Modified: 2012-05-10
I need to populate a combobox with values from a dataset. When running the code below, I recieve "Cannot bind to the new display member.Parameter name: newDisplayMember". Any suggestions?

        DAL rating = new DAL();
        DataSet ds = rating.getRatings("SELECT * FROM tblRating");
        cboRating.DataSource = ds;
        cboRating.DisplayMember = "Rating"; //Colunm name for display
        cboRating.ValueMember = "RatingID"; //Primary key <----Error here
0
Comment
Question by:98fatboyrider
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 1000 total points
ID: 34132618
DataSets usually contain DataTables, and it is usually the DataTable that you bind to.

Try:

        cboRating.DisplayMember = "Rating"; //Colunm name for display
        cboRating.ValueMember = "RatingID"; //Primary key

        cboRating.DataSource = ds.Tables[0];

Open in new window


If that doesn't work then check to make sure that you are pulling back a column named "RatingID".
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question