Hi all, I'm writing an app for PocketPC with .NET CF (C#), and am having some trouble with the data layer. A lot of people seem to have noticed that XML is pretty slow on CF, and so I thought I'd switch to SQL CE. What I was doing wasn't very involved: I need a datagrid bound to a dataset ( 1 Table, 65 fields, 25 - 100 rows). So at first I simply did:
DataSet ds = new DatSet();
ds.ReadXml(filename);
This takes a REALLY long time, about 20 sec. for 26 rows, (although I got it down to 14 sec. after the CF Service Packs) So I read in a post at .NET 247 that SQL Server CE would be a great deal faster for this sort of thing, but the thing is I'm finding it to actually be SLOWER. Am I doing something wrong?
Basically I did this:
SqlCeConnection conn = new SqlCeConnection(connStr);
conn.Open();
SqlCeCommand cmd = new SqlCeCommand("SELECT * FROM myTable", conn);
SqlCeDataReader reader = cmd.ExecuteReader();
//DataRow dr;
object[] values = new object[ds.Tables[0].Columns.Count];
while(reader.Read())
{
//reader.GetValues(values);
values[0] = reader.GetString(0);
//ds.Tables[0].Rows.Add(values);
}
And it actually took LONGER than the ReadXml method. I even noticed that it's pretty slow just using the SQL Query tool installed on my PocketPC.
Although I can get better performance out of a page or so of code using the raw XmlTextReader, this is a bit of a pain - I have to format all the column names, read the attributes and set the data types etc. Is there anything I can do to speed this up? Everyone is writing these articles about how great SQL CE is, and I use SQL2000 a lot and it's crazy fast, so I figure I must be doing something wrong.
Thanks for any help,
Nick