// Loading data from database into comboBoxRoomType private void LoadDataRoom() { // Fetch dataset DataSet roomtypeListDS = DBGetData.GetRoomtypeList(); if (roomtypeListDS != null) { // No tables fetched if (roomtypeListDS.Tables.Count == 0) { MessageBox.Show("No roomtype datatable found, contact administrator."); return; } // No rows fetched else if (roomtypeListDS.Tables[0].Rows.Count == 0) { MessageBox.Show("No datarows found in roomtype table."); return; } // Set the dataset as source for combobox comboBoxRoomType.ValueMember = "room_typeid"; comboBoxRoomType.DisplayMember = "name"; comboBoxRoomType.DataSource = roomtypeListDS.Tables[0]; } // Highlight existing values textBoxRoomid.Text = roomid.ToString(); MySqlDataReader getValues = DBGetData.GetFloorplanRoomData(roomid); if (getValues.Read()) { comboBoxRoomType.SelectedValue = getValues.GetInt32(0); } getValues.Dispose(); }