I've seen a lot of examples for asynchronous when trying to do Web downloading/reading. But I fail to find a sample or anything for OleDb (or is there a better equivalent?), I'd like to use the new and simplified Async and Await features of C# 5.0.
This is just an example of how I use OleDb now:
public void insertTafelloc(int tafelnr, string datum, string tijd)
{
tafelsupdate = false;
try
{
db.cmd.Connection = db.connection;
db.connection.Open();
db.cmd.CommandText = "SELECT * FROM tafels WHERE tafelnr = ? AND datum = ?";
db.cmd.Parameters.Add(new OleDbParameter("1", tafelnr));
db.cmd.Parameters.Add(new OleDbParameter("2", datum));
OleDbDataReader dataReader;
dataReader = db.cmd.ExecuteReader(CommandBehavior.CloseConnection);
while (dataReader.Read())
{
if (dataReader["tafelnr"].ToString() != "")
{
tafelsupdate = true;
}
}
dataReader.Close();
db.cmd.Parameters.Clear();
db.connection.Close();
}
catch (Exception ex) { MessageBox.Show(ex.Message); }
}
I do run a few data readers after each other, multiple times on request, and it's taking quite a while before the new results are showing on the Form. Also, I'm using OleDb to access a Access database.