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 .

Edited 6 Years Ago by LennieKuah: type error

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.

Edited 6 Years Ago by LennieKuah: type error

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.

This question has already been answered. Start a new discussion instead.