There are quite a few problems to fix. Consider the following alternative
string sql;
DataSet dsa = new DataSet();
DataTable dt = new DataTable();
dsa.Tables.Add(dt);
using (OleDbConnection connection = new OleDbConnection(connectionString)) {
sql = @"SELECT *
FROM [Sales Record]
WHERE [Cash Sales] = 'Cash Sales'
AND [Date] = @datecriteria";
OleDbDataAdapter da =new OleDbDataAdapter(sql, connection);
da.SelectCommand.Parameters.Add("@datecriteria", OleDbType.Date).Value = System.DateTime.Now;
try {
connection.Open();
adapter.Fill(dt);
}
catch (Exception ex) {
}
}
It's vital to always use parameters to prevent yourself from
SQL injection[
^] and to use using blocks to ensure proper disposal of resources.
What comes to the criteria itself it looks a bit odd that you're concatenating a static text to the where clause and that you use current time for the criteria. Just guessing but if you want to search for records for today, instead of
da.SelectCommand.Parameters.Add("@datecriteria", OleDbType.Date).Value = System.DateTime.Now;
use
da.SelectCommand.Parameters.Add("@datecriteria", OleDbType.Date).Value = System.DateTime.Now.Date;