it was working perfect
I wanted to make a lite version of it using Access database to be used on weak PCs
So I changed the connection string as this:
internal static string dataPath = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=BPAS.accdb";
I changed all objects from SqlClient to Oledb
/*
SqlDataAdapter da = new SqlDataAdapter();
SqlCommand cm = new SqlCommand();
SqlConnection cn = new SqlConnection(Program.dataPath);//HeMa
DataSet ds;
SqlDataReader reader;
SqlDataReader _dr;
*/
OleDbDataAdapter da = new OleDbDataAdapter();
OleDbCommand cm = new OleDbCommand();
OleDbConnection cn = new OleDbConnection(Program.dataPath);//HeMa
DataSet ds;
OleDbDataReader reader;
OleDbDataReader _dr;
I changed date search in queries from "where [date] = '" + dateObject + "'"
to "where [date] = #" + dateObject + "#"
I changed the like parameter from % to *
I already opened the access database and executed the queries in the applications myself and they all returned the expected results
but in the application each time it returns 0 rows
NO EXCEPTIONS
Just 0 rows
here is the connection declaration
cm.Connection = cn;
cm.CommandTimeout = 28800;
cm.CommandType = CommandType.Text;
try
{
cn.Open();
}
catch (Exception ex) { MessageBox.Show(ex.Message, "Error : [P707]", MessageBoxButtons.OK, MessageBoxIcon.Warning); }
and here is one example of my queries
cm.CommandText = "select * from Results where [Name] like '*" + txtSearch.Text + "*'";
//da = new SqlDataAdapter(cm);
da = new OleDbDataAdapter(cm);
ds = new DataSet();
da.Fill(ds, "Results");
dgSearch.DataSource = ds.Tables["Results"];
try
{
cn.Close();
}
catch { }
this always returns 0 rows

New Topic/Question
Reply




MultiQuote








|