I have written a program to save attendance of employees.The database engine is MS Access. when I execute a query form the C# program using Data-Adapter it does not return values, but when I’m executing the same query in Access it gives results. I have used one table join in the query
OdbcConnection conn = new OdbcConnection(Variables.ConnectionString);
conn.ConnectionTimeout = 50;
if (conn.State != ConnectionState.Open) conn.Open();
string query = "SELECT l.matchine_number, e.actual_emp_number, e.user_name, e.location_name, l.date_time FROM tbl_log l " +
"RIGHT OUTER JOIN tbl_enroled_users AS e ON e.enroled_emp_number = l.enroled_number " +
"WHERE " +
"l.matchine_number LIKE '*" + txtMatchineNumber.Text + "*' AND " +
"e.actual_emp_number LIKE '*" + txtEmpNumber.Text + "*' AND " +
"e.user_name LIKE '*" + txtName.Text + "*' AND " +
"e.location_name LIKE '*" + txtLocation.Text + "*' AND " +
"l.date_time >= #" + dtFrom.Value.ToString("M/d/yyyy") + " 12:00:00 AM# AND " +
"l.date_time <= #" + dtTo.Value.ToString("M/d/yyyy") + " 11:59:59 PM# " +
"ORDER BY l.matchine_number, e.actual_emp_number, e.user_name, e.location_name, l.date_time";
OdbcDataAdapter adptr = new OdbcDataAdapter(query, conn);
DataTable dt = new DataTable();
adptr.Fill(dt);
if (conn.State != ConnectionState.Closed) conn.Close();
Please Help
without any error-messages or the generated query-string it’s just guessing. but my idea is that the wildcards you’re using are not correctly interpreted. Try to change * into % and see if it works.