![]() ![]() write exception info to log or anything else SqlDataAdapter da = new SqlDataAdapter(query, conn) ĬmbTripName.DataSource = ds.Tables ![]() ![]() using (SqlConnection conn = new Source=SHARKAWY Initial Catalog=Booking Persist Security Info=True User ID=sa Password=123456")) Instead of using a dataReader to access the values I choosed a dataTable and bound it as dataSource onto the comboBox. DisplayMember and ValueMember point to columnNames! Furthermore you should really use a using block - so the connection gets disposed (and closed) after query execution. You will have to completely re-write your code. ![]() It's working now but when I click the button to show the data private void button1_Click(object sender, EventArgs e) The data is presented in the combobox, but when you change the selection valuemember the displaymember does not change. SqlCommand cmd = new SqlCommand(query, conn) Ĭ(drd.ToString()) ĬmbTripName.ValueMember = drd.ToString() ĬmbTripName.DisplayMember = drd.ToString() String query = "select FleetName, FleetID from fleets" My code: SqlConnection conn = new SqlConnection() Ĭonn = new Source=SHARKAWY Initial Catalog=Booking Persist Security Info=True User ID=sa Password=123456") ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |