Hi!
I have a combobox with three items:
ToyotaKiaHyndaiThen I have a small table with two columns (Marks and Models):
Marks | Modelos
Toyota: CamryToyota: CelicaToyota: CorollaKia: OptimaKia: PicantoKia: SportageHyundai: AccentHyundai: AzeraHyundai: ElantraWhen I select one mark. What happening? I found in the combobox model the table's name repeted in that combobox:
string connectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\rentacar\rentacar\\app_data\rentacar.mdb;Persist Security Info=False";
OleDbConnection sqlCon = new OleDbConnection(connectionString);
sqlCon.Open();
string commandString = "select * from carsconfig where cars ='" + cbxMarkConfig.Text + "'";
OleDbCommand sqlCmd = new OleDbCommand(commandString, sqlCon);
OleDbDataReader read = sqlCmd.ExecuteReader();
if (read.HasRows)
{
while (read.Read())
{
cbxModelsConfig.Items.Add("models"); // it will show the code
}
}
else
{
MessageBox.Show("A record with a code of " + cbxMarkConfig.Text + " was not found");
}
}
}