Rao Varrey

Rao Varrey

  • NA
  • 56
  • 3k

Can somebody point out the errors in coding....

Oct 16 2017 12:50 AM
OdbcConnection myConnection = new OdbcConnection();
OdbcCommand cmdCombo = myConnection.CreateCommand();
OdbcCommand cmdList = myConnection.CreateCommand();
string myConnectionString = @"Driver={Microsoft Access Driver (*.mdb)};" + "Dbq=C:/DROPS-Data/Derrick.mdb";
{
myConnection.ConnectionString = myConnectionString;
myConnection.Open();
//execute queries, etc
cmdCombo.CommandText = "SELECT * FROM DerrickAreas";
OdbcDataReader readerCombo = cmdCombo.ExecuteReader();
if (readerCombo.HasRows)
{
while (readerCombo.HasRows)
{
comboBox1.Items.Add(readerCombo["Section"].ToString());
readerCombo.NextResult();
}

}
else
{
MessageBox.Show("No records");
}
myConnection.Close();
 
I am trying to populate the comboBox with data from Access database, which has 8 records, but it is showing only the first record 
Can somebody point out the errors in this code 

Answers (5)