I have a mess with trying to read line by line from a MS Access database and display it on the screen when between every display there are a few seconds of sleeping.
I am using System.Threading
as you can see but it seems the sleeping is happening before the program displays the records and when the sleeping is over only the last record is displayed without displaying the previous.
Here is my code, I will really appreciate any help!
private void com_start_Click(object sender, EventArgs e)
{
try
{
string ConString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\MyBrainWash\Englishdb.accdb;";
OleDbConnection Con = new OleDbConnection(ConString);
Con.Open();
check_connection.Text = "succeeded";
OleDbCommand command = new OleDbCommand();
command.Connection = Con;
command.CommandText = "Select * From words";
OleDbDataReader reader = command.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
lab_word.Text = reader["word"].ToString();
lab_definition.Text = reader["definition"].ToString();
Thread.Sleep(30000);
}
}
reader.Close();
Con.Close();
}
catch (Exception ex)
{
MessageBox.Show("Error " + ex);
}
}