1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| private int SelectMDB(String file, String table, String request, DataGridView datagridview)
{
int result = 0;
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
try
{
string connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + file + ";";
OleDbConnection connection = new OleDbConnection(connetionString);
OleDbDataAdapter dataadapter = new OleDbDataAdapter(request, connection);
DataSet ds = new DataSet();
connection.Open();
dataadapter.Fill(ds, table);
connection.Close();
result = ds.Tables[0].Rows.Count;
datagridview.DataSource = ds;
datagridview.DataMember = table;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
stopWatch.Stop();
// Get the elapsed time as a TimeSpan value.
TimeSpan ts = stopWatch.Elapsed;
// Format and display the TimeSpan value.
string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds);
Console.WriteLine("Select execute en : " + elapsedTime);
return result;
} |
Partager