SqlCe odd results why? -- Same SQL, different results in different apps. Issue with
Posted
by NitroxDM
on Stack Overflow
See other posts from Stack Overflow
or by NitroxDM
Published on 2010-01-07T07:18:18Z
Indexed on
2010/05/09
4:18 UTC
Read the original article
Hit count: 357
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!
© Stack Overflow or respective owner