المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : C# Fill comboBox with DB content



C# Programming
06-02-2013, 04:43 PM
I want to Bind two Columns and populate a ComboBox with it in C#..My code is printing just one. the FirstName. Have tried concatenating the LastName with it but its not working. Can anyone show me how to go about it. Here is my code. Thanks
OleDbCommand cmd = new OleDbCommand("SELECT * FROM ADb", myCon); OleDbDataAdapter d = new OleDbDataAdapter(cmd); d.SelectCommand.CommandText = cmd.CommandText.ToString(); DataTable dt = new DataTable(); d.Fill(dt); cmbNames.DataSource = dt; cmbNames.DisplayMember = "FirstName";