DEVBUZZ Homepage Harnessing SSCEDirect for fast SQLCE data loading
 
Web www.devbuzz.com
  HOME PAGE
  All Articles
  Advertise
  Consulting

 Development
  Discuss - Forums
  Still in the box?
  .Compact Framework
  Code Snippets
  SQL Server CE
  Database
  MS Resources
 Stores
  Developer Controls
  Pocket PC Hardware
  Pocket PC Software
  Pocket PC Books
  .NET CF Books
  Book Reviews
  SPB SW Discounts
  RESCO SW Discounts
 DEVBUZZ Info
  About Us
  Help
  Join our email list
  Links & Ratings
  Press & Comments
  Pocket PC version
  Software Reviews
  Hardware Reviews
 Authors
  Authors
  Article Guide
  Competitions
 Resources
  Developers
  Register
  Login

  SPB Discounts!
 Columnists
  Rick Winscot
 Past Blast
  Personal Media Ctr
  Gizmobility
  eVB Legacy
  Old news
  Hosted Software
  Wireless
  Newsletters
  Carl Davis
  Upton Au

 Pocket PC Registry
  Join the registry
  View current list
 Current Poll
Are you converting to .NET Compact Framework?
Yes, it has changed my life!
No, I'm sticking with eVB
.NET CF what's that`?

Current results
3431 votes so far
 Recent Forum Threads [goto forums]

Get Computername
read... (67 hits)


Great aid to development productivity
read... (82 hits)


ThreadingTimer sample code
read... (143 hits)


Multithreading with .NET CF
read... (194 hits)


Moving from eMbedded Visual Basic to Visual Basic .NET
read... (166 hits)


.NET Compact Framework 2.0 Service Pack 2
read... (226 hits)


Transfer Data from SQL Server 2000 to SQL Server Compact Edition
read... (298 hits)


This protocol version is not supported
read... (236 hits)


Converting Lowercase to uppercase wont work
read... (203 hits)


Direct access to MS SQL Server 2000
read... (374 hits)


Creating SDF file in Desktop
read... (513 hits)


Winsock in CF.NET
read... (316 hits)


Using Pocket Outlook to submit HTML page form with MAILTO action
read... (420 hits)


Missing file "System.Data.PocketPC.asmmeta.dll"
read... (268 hits)


HP iPAQ hw6915 Serial Port Issue
read... (309 hits)


Info on the recent forum changes
read... (341 hits)


SqlServer tools from Redgate
read... (383 hits)


Arrow keys and Hardware navigation button
read... (393 hits)


O2 XDA lls pin sync cable to comport
read... (322 hits)


Creating dynamic folders on Pocket PC OS
read... (299 hits)

Custom Windows Mobile software development.
LBS Challenge 2007
LBS Challenge Eight previous NAVTEQ Global LBS Challenge® participants have received venture capital funding and nine past LBS Challenge winners have launched commercial applications on major wireless carriers. Register your non-commercial LBS application in the 2007 NAVTEQ Global LBS Challenge in one of three regions: Americas, Europe-Middle East-Africa (EMEA) or Asia-Pacific(APAC). You could win a share of $2 million in prizes. This could be your year.
Dream. Develop. Win.

Development | .NET Compact Framework

Harnessing SSCEDirect for fast SQLCE data loading
Written by brady moritz  [author's bio]  [read 29340 times]
Edited by Derek

SQL Server CE 2.0   

Page 1  Page 2 

When Microsoft released Sql Server CE, developers for Pocket PC and CE based devices were given a excellent platform for building data intense mobile applications. This mobile database engine provides a set of features that are very similar to the full-scale Sql Server product, which are enhanced by powerful replication capabilities for keeping this data syncronized with a backend Sql Server. Since the majority of mobile applications use local databases as a form of cache for server-based data, this syncronization capabilities is very useful. Sql Ce became even more useful when the .Net compact framework was released as it could then be utilized via ADO.Net interfaces with a powerful object-oriented language.

As mobile solutions continue to grow in popularity, developers are increasingly facing data connectivity challenges and are not always able replicate their backend data from a Sql Server. Legacy data can be exposed in a variety of ways and many systems are exposing data via a more generic XML or Webservice interface, and mobile developers are increasingly interfacing with these sources.

However, when a mobile developer attempts to use ADO.Net to syncronize more than a few records with these alternative data sources, they often discover the hard way that performance issues can make this a very slow operation. The process of downloading an XML or flat file and trying to load it into SQL CE via an ADO.Net DataSet can take a number of minutes for a few thousand records. 10,000 records can even require 10 minutes! With growing memory capacities of modern devices, mobile data requirements can easily expand into many tens or even hundreds of thousands of records.

SSCEDirect is a product recently release by Fitiri Inc. as a way to speed up these bulk data loading operations with Sql Server CE. Performance improvements seen with a sample 10,000 records is a reduction from 10 minutes using a DataSet to approx 20 seconds using SSCEdirect.

Lets walk through a simple example of how to use the SSCEDirect software (Fitiri offers a demo version at their website that allows you to try the full features, but will randomly alter some of your database varchar data). You can request a demo of the software at this url: http://www.fitiri.com/SSCEDirect.html

Lets review some example C# source code to do a performance comparison. The first example will use a DataSet to insert new records into a Sql Ce database. Code to track elapsed time should be added here to calculate how long it takes, but is left out of this example to keep it cleaner.

public void SampleLoad(){

DataSet ds = new DataSet();

//We will manually load a dataset for this example, normally this would be
//done by loading data from serialized XML.

DataTable dt = new DataTable("sampletable");
dt.Columns.Add(new DataColumn("col1", typeof(System.Int32)));
dt.Columns.Add(new DataColumn("col2", typeof(System.String)));
dt.Columns.Add(new DataColumn("col3", typeof(System.String)));
dt.Columns.Add(new DataColumn("col4", typeof(System.DateTime)));
dt.Columns.Add(new DataColumn("col5", typeof(System.Decimal)));
dt.Columns.Add(new DataColumn("col6", typeof(System.Double)));
dt.Columns.Add(new DataColumn("col7", typeof(System.Single)));
dt.Columns.Add(new DataColumn("col8", typeof(System.Int64)));
dt.Columns.Add(new DataColumn("col9", typeof(System.Boolean)));
dt.Columns.Add(new DataColumn("col10", typeof(System.Guid)));
dt.Columns.Add(new DataColumn("col11", typeof(System.Int16)));
dt.Columns.Add(new DataColumn("col12", typeof(System.Byte)));
dt.Columns.Add(new DataColumn("col13", typeof(System.Decimal)));

//add (cnt) dummy records to the dataset.
for(int i = 0; i< cnt; i++)
{
DataRow dr = dt.NewRow();
dr[0]=123456;
dr[1]="This is a string of data to be inserted";
dr[2]="some nchar data";
dr[3]=DateTime.Now;
dr[4]=(Decimal)(123456789012345);
dr[5]=(Double)56789.123;
dr[6]=(Single)123.456;
dr[7]= 112233445566;
dr[8] = true;
dr[9] = new Guid(1,2,3,4,5,6,7,8,9,0,1);
dr[10] = (Int16)12345;
dr[11] = (Byte)123;
dr[12] = (Decimal)(123.1266666);
dt.Rows.Add(dr);
}
dt.AcceptChanges();

//add the DataTable to the DataSet object
ds.Tables.Add(dt);

//this is a way to get the schema from the database table, without filling any data.
da = new SqlCeDataAdapter("select * from sampletable where 1 = 0",conn);
da.FillSchema(ds,SchemaType.Mapped, "sampletable");

//force the DataAdapter to generate the insert command, can also be manually set.
cb = new SqlCeCommandBuilder(da);
da.MissingMappingAction = MissingMappingAction.Passthrough;

//seems this is needed to force the insert command to be assigned.
da.InsertCommand = cb.GetInsertCommand();

//call update to move all the data from sampletable DataTable into the database table
da.Update(ds, "sampletable");
da.Dispose();
}

Next Page 

Back to .NET Compact Framework | [Article Index]

 

Back to the top of the page.
Chris De Herrera's Windows CE Website Windows CE News & Information Source
Copyright ©2000-2007 by DEVBUZZ.COM, Inc., NJ. USA.MSDEVELOP