Transfer data faster
-
hi guys Im transfering data from sql server 2005 to comapact framework database (*.sdf) My way to do so is : Export the table into an XML file (using DataTable) dt.WriteXml(FName, System.Data.XmlWriteMode.IgnoreSchema) And on the mobile device I load the XML and save the Dataset dt.ReadXml(FileName) da.Update(DataSet11) Everything is working only my table contains about 1500 records (20 fields) and it takes about 6 minutes to load and save. Is there any way or Method to do this any faster ? Thanks in Advance Dan.
-
hi guys Im transfering data from sql server 2005 to comapact framework database (*.sdf) My way to do so is : Export the table into an XML file (using DataTable) dt.WriteXml(FName, System.Data.XmlWriteMode.IgnoreSchema) And on the mobile device I load the XML and save the Dataset dt.ReadXml(FileName) da.Update(DataSet11) Everything is working only my table contains about 1500 records (20 fields) and it takes about 6 minutes to load and save. Is there any way or Method to do this any faster ? Thanks in Advance Dan.
Rather ironically for something called 'SQL Server CE', the SQL language is the worst, slowest way to do anything. If you're using .NET Compact Framework 2.0, the solution for loading data that's the fastest to execute while still being pretty readable and maintainable is to use the
SqlCeResultSet
class. To do this, create aSqlCeCommand
, passing just the name of the table to modify in the query text parameter. Then set the command type toCommandType.TableDirect
. Associate it with an openSqlCeConnection
and callExecuteResultSet
, using theResultSetOptions.Updatable
option. Then, on theSqlCeResultSet
, callCreateRecord
to get a new record, set the record's properties, then callInsert
to insert it into the table. See SQL Server Compact Edition Insert Performance[^] for details on just how big a difference this makes. Equally, a direct table access operation is far, far faster than SELECTing from that table - not just time to first row being returned, but even the time to access each subsequent row. To access the results in a particular order, you can use theIndexName
property to use a named index on the table, and you can use theSetRange
method to restrict the set of results that are returned.
DoEvents
: Generating unexpected recursion since 1991 -
hi guys Im transfering data from sql server 2005 to comapact framework database (*.sdf) My way to do so is : Export the table into an XML file (using DataTable) dt.WriteXml(FName, System.Data.XmlWriteMode.IgnoreSchema) And on the mobile device I load the XML and save the Dataset dt.ReadXml(FileName) da.Update(DataSet11) Everything is working only my table contains about 1500 records (20 fields) and it takes about 6 minutes to load and save. Is there any way or Method to do this any faster ? Thanks in Advance Dan.
dandi18 wrote:
Is there any way or Method to do this any faster ?
Yes. Use SharpZipLib (also known as NZipLib) CF library to compress the files before sending them over. You can get it here: http://www.icsharpcode.net/OpenSource/SharpZipLib/Download.aspx[^]
Pete Soheil DigiOz Multimedia http://www.digioz.com