views:

157

answers:

2

hi

what is the fast way to find and data in sqlCE in windows-mobile (C#) ?

i have database with 1000000 records.

sql query ? .... or data reader ?.....or wat ??

thank's in advance

+1  A: 

Use an index for your where clause and a SqlConnection.

James Black
While I'm speaking out of my knowledge zone since it's mobile (assuming this exists and is the same) make sure you use ExecuteReader or the similar method that you can read from a DataReader instead of a DataSet/DataTable as they are extremely ineffecient compared to the Reader. Make sure you keep all of your readers and sql connections in `USING()` constructs so that they are properly released too.
Chris Marisic
thank's for the help, can i get sample code ?
Gold
To connect you can look at http://stackoverflow.com/questions/793128/connecting-to-sql-ce-db-using-sqlconnection and http://stackoverflow.com/questions/1125846/whats-wrong-with-this-sqlce-query
James Black
Just useing a WHERE clause means you're using the query processor, which is slow.
ctacke
If you are using any database you need a WHERE clause, otherwise you are selecting everything. If you are using indexes in your where clause it will be very fast, faster than parsing a file yourself to find the data.
James Black
+1  A: 

By far the fastest way is to not use the query processor at all. Index the table to the field you want to search on and then use a SqlCeCommand with TableDirect and open a reader. Just adding the query procesor makes it an order of magnitude slower.

ctacke