When I run this SQl in my mobile app I get zero rows.
select * from inventory WHERE [ITEMNUM] LIKE 'PUMP%' AND [LOCATION] = 'GARAGE'
When I run the same SQL in Query Analyzer 3.5 using the same database I get my expected one row.
Why the difference?
Here is the code I'm using in the mobile app:
SqlCeCommand cmd = new SqlCeCommand(Query);
cmd.Connection = new SqlCeConnection("Data Source="+filePath+";Persist Security Info=False;");
DataTable tmpTable = new DataTable();
cmd.Connection.Open();
SqlCeDataReader tmpRdr = cmd.ExecuteReader();
if (tmpRdr.Read())
tmpTable.Load(tmpRdr);
tmpRdr.Close();
cmd.Connection.Close();
return tmpTable;
UPDATE: For the sake of trying I used the code found in one of the answers found here and it works as expected. So my code looks like this:
SqlCeConnection conn = new SqlCeConnection("Data Source=" + filePath + ";Persist Security Info=False;");
DataTable tmpTable = new DataTable();
SqlCeDataAdapter AD = new SqlCeDataAdapter(Query, conn);
AD.Fill(tmpTable);
The issue appears to be with the SqlCeDataReader.
Hope this helps someone else out!