I use ExecuteScalar
for single query like this:
try
{
OleDbConnection Connection;
using (Connection = new OleDbConnection("Provider=MSDAORA.1;Data Source=DATABASE:1521/orcl;Persist Security Info=True;Password=PASSWORD;User ID=USERNAME"))
{
OleDbCommand Command1, Command2, Command3;
Command1 = new OleDbCommand("SELECT HOUR FROM Table1 WHERE type='CAR' and name='FERRARI'",", Connection);
Command2 = new OleDbCommand("SELECT HOUR FROM Table1 WHERE type='CAR' and name='FORD'", Connection);
Command3 = new OleDbCommand("SELECT HOUR FROM Table1 WHERE type='CAR' and name='OPEL'", Connection);
Connection.Open();
var1 = (int)Command1.ExecuteScalar();
var2 = (int)Command2.ExecuteScalar();
var3 = (int)Command3.ExecuteScalar();
Connection.Close();
}
It's working fine for me. But 3 (and more for other databases) query waiting so much because of database. How can I select all table (select * from Table1) and after execute commands for every where condition? Can you show me example for this on my sample code? Thank you.