Hi Good Guys,
I am learning how to use C#Net2008 to develop Window Application. I was a VB.NET2008 developer. I need your help, Please Help me.

I am encountering 2 problem trying to fill LISTBOX with DATASET and CATCH to display error message.

In the LISTBOX dropdown list instead of displaying CUSTOMERNAME, it display System.Data.DataViewManagerListItemTypeDescriptor

private void FLoadListBox()
        {
            string strSql  = "Select CustomerID, CompanyName from  Customers Order by CompanyName";
            sqlconn = new SqlConnection(connstr);
            sqlconn.Open();
            sqlDA = new SqlDataAdapter(strSql, sqlconn);
            DS = new DataSet("DS");

            try
               {
                DS.Clear();
                DS.CaseSensitive = true;
                sqlDA.Fill(DS,"Cust");

                // fill listbox
                this.listBoxCust.DisplayMember = "CompanyName";
                this.listBoxCust.ValueMember = "CustomerID";
                this.listBoxCust.DataSource = DS;
                sqlconn.Close();
               }
            catch (SystemException MsgException)
               {
            
               }
            
   }

Thank you .

Qualify the fields.

this.listBoxCust.DisplayMember = "Cust.CompanyName";
this.listBoxCust.ValueMember = "Cust.CustomerID";
this.listBoxCust.DataSource = DS;

Hi AdataPost,
Thank for your suggestion. Will try it out and get back to you.
If the coding is running well, I will post it here to share with other Newbies who may have similar problems.

Hi Good Guys,
Thanks to all of you for sharing your knowledge and information with me.
I am learn alot from it and now my coding is working.

You're welcome.

I'm glad you got it working. Please mark this thread as solved

Thanks to this wondeful FORUM whose members are so helpful and generous in sharing their knowledge with me. I am so glad that I have registered myself here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.