steve lasker program manager microsoft corporation blogs.msdn.com/stevelasker pc40

33
Notes (hidden)

Upload: mavis-hancock

Post on 16-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Notes (hidden)

Page 2: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Embedding SQL Server Compact In Desktop And Device Applications

Steve LaskerProgram ManagerMicrosoft Corporationblogs.msdn.com/SteveLasker

PC40

Page 3: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Why data on the client is important How SQL Server Compact “changes

the game” Performance Best Practices

Differences between Compact & Express Getting the most by understand

the architecture Interesting ways to leverage local data

Custom Document Format Run directly from a DVD Visibility into Client Application Health

What we'll cover today…

Page 4: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Read Only, Reference Data Is it 100% static for the life of a version? Are there changes? (list of States,

Product Catalog?) Is it 100% the same for all users?

User Data Each user has “their data” and they

make changes Orders, My Customers, Settings

Aggregation Ability to slice and dice on data across

various sources

Types Of Local Data

Page 5: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Caching Simplifies Data Access

Offloads detailed questions to the client Enables local processing, closer to the user

Enables offline scenarios

Products w/’a’Products > 5,Products in Category 2,Products Discontinued,Most sold products for last 3 months

What’s changed for my data Added, Updated, Deleted

Top Products for My Customers

Page 6: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Clients ServersFrom desktop to data centerFrom embedded devices to desktops

Synchronizing data from the point of activity to the data center

Enabling data movement from the smallest device, capturing data at the point of activity through the largest data center, to the offsite cloud

CloudTo hosted services

Page 7: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Best practices, not all that different Architectural differences, but suited to the task Choose your weapon

One Size Fits All?

Page 9: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

How Compact “Changes The Game” What good is a

database if you can’t deploy it?

demo

Page 10: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Deploying Target = Any

Change Managed Provider reference to Copy Local = true

Include both 32 and 64 bit Compact engine dlls Place 32bit version under an X86 Place 64bit version under AMD64

AMD64 includes Intel X64Folder Name based off:

Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE")

Page 11: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

SQL Server Compact DLLs

DLL Name Functionality

sqlcese35.dll Native* Storage Engine

sqlceqp35.dll Native* Query Processor

sqlceme35.dll Native / Managed Translation Layer

System.Data.SqlServerCe.dll ADO.NET Managed Provider

sqlcecompact35.dll Compression & Upgrade APIs

sqlceca35.dll Merge Replication, RDA Client APIsOnly needed for Merge & RDA, Not needed for Sync Services for ADO.NET

sqlceoledb35.dll OleDB API –Needed for C++, VB Classic, & Merge/RDAOleDB APIs Designed for Mobile DevicesNot a full desktop OleDB Implementation

sqlceer35EN.dll Localized Error Strings Only needed when errors returned directly to the user

Page 12: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

One Size Fits All?

Architectural Comparison

Page 13: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Architectural Comparisons

SQL Server (Express*)

Shared Data ServicesSQL Server CompactLocal Data Documents

Multiple Connections from multiple clients

Multiple Connections from multiple processes & threads

Runs as a service Runs In-Proc w/ApplicationMulti-proc access through shared memory

Connection Poolingthrough SqlClient

Connections through SqlCeConnection

Query Plans cached in SQL Server Engine

Query Plans cached in SqlCeCommand object

Page 14: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Performance Best Practices

Eeeking out that extra bit of performance

DemoSqlCeCommand cmd = conn.CreateCommand();cmd.Parameters.Add("@name", System.Data.SqlDbType.NVarChar, 50);while (reader.Read()) {

cmd.CommandText = "INSERT INTO Customer (CustomerId, Name) VALUES(@id, @name";

cmd.Parameters["@customerId"].Value = id;

Page 15: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Best Practices – Performance

Parameterized Commands, with type and precision

cmd.CommandText = "Customer";cmd.CommandType = System.Data.CommandType.TableDirect;SqlCeResultSet rst = cmd.ExecuteResultSet(ResultSetOptions.Updatable);SqlCeUpdatableRecord newRow;while (reader.Read()) {

newRow = rst.CreateRecord();newRow["customerId"] = customerId;newRow[“name"] = name;rst.Insert(newRow);

SqlCeCommand cmd = conn.CreateCommand();cmd.Parameters.Add("@customerId", System.Data.SqlDbType.Int);cmd.Parameters.Add("@name", System.Data.SqlDbType.NVarChar, 50);cmd.CommandText = "INSERT INTO Customer (CustomerId, Name) VALUES(@id, @name");while (reader.Read()) {

cmd.Parameters["@customerId"].Value = id;cmd.Parameters["@name"].Value = name; Bulk Insert w/SqlCeResultSet

Page 16: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

"Bulk Load" Performance

New Commands

Cached Comman

ds

Parameteriz

ed Commands

Params w

/Size

SqlCeResu

ltSet

0

50

100

150

200

250

300

350

400

Device

Inse

rts/

Seco

nd

New Commands

Cached Comman

ds

Parameteriz

ed Commands

Params w

/Size

SqlCeResu

ltSet

0

2000

4000

6000

8000

10000

12000

Desktop

Page 17: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Deferred Index Creation

New Commands

Cached Comman

ds, Single

TX

Parameteriz

ed Commands -

Singl.

..

Params w

/Size

Params w

/Size

, w/E

ncryption

SqlCeResu

ltSet

0

2000

4000

6000

8000

10000

12000

14000 Active Index Post Index

Page 18: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Using Trace Listener To Gather Information In The Field

Page 19: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Monitoring Client HealthAcme WidgetsData Center

?• How to see what’s happening at the client?• Clients aren’t reachable

• Either aren’t Online when you need them• Or they’re not addressable with a static IP

• What to do?• Phone home?

Page 20: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Web Service TraceListnerAcme WidgetsData Center

Web Service TraceListener

try { barcode = scanner.Scan();} catch (Exception ex) { Trace.WriteLine("Scan Failed - " + ex.Message, "Barcode Scanner");}

Trace.Listeners.Add(new WebServiceTraceListner("http://MyTraceService.svc"))

try { productInfo = productSvc.GetProductInf(barcode);} catch (NetworkException ex) { Trace.WriteLine(“UnableToConnect - " + ex.Message, “Product Lookup")}

Page 21: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

SQL Server Compact TraceListnerAcme WidgetsData Center

Sync Servicesto move Log info when

a connection is available

Compact TraceListener

try { productInfo = productSvc.GetProductInf(barcode);} catch (NetworkException ex) { Trace.WriteLine(“UnableToConnect - " + ex.Message, “Product Lookup")}

Trace.Listeners.Add( new SqlCeTraceListner("Log.sdf", "http://LogSyncService.svc"));

Page 22: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Using Trace Listener to Gather Information in the Field

Getting visibility to what’s actually going on

demo

Page 23: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

SQL Server Compact TraceListenerAcme WidgetsData Center

Page 24: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Structured document Single file, code free, email attachment safe Post “Documents” to SharePoint Create custom extensions, map to your app Password protect, requiring users to open

documents w/your app File Associations Supported by

Visual Studio 2008 & ClickOnce

Custom Doc Formats

Page 25: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Using a SQL Server Compact Database as a Document

ClickOnce, w/.NET FX 3.5 enables file associations

demo

Page 26: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Why data on the client is important Power of the client, freedom to add value

How SQL Server Compact “changes the game” No need to worry about deployment

Performance Best Practices Take advantage of the in-proc nature

Interesting ways to leverage local data Custom Document Format Run directly from a DVD Visibility into Client Application Health

Recap

Page 27: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

SQL Server Compact ~1mb embedded database, no

brainer deployment It’s free, fast, safe/encryptable and compact It’s easy to program and manage Single file, code free, doc centric file format It’s an alternative to JET, XML, Persisted DataSets,

SQL Server Express It’s integrated into:

Visual Studio 2005 SP1 Visual Studio 2008 (Orcas)

Adds Sync Services for ADO.NET SQL Server Management Studio 2008 (Katmai) 3.1 In ROM for Windows Mobile 6.x

Summary

Page 28: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Related Content

TL40 Microsoft Sync Framework Advances– Lev Novik Day 1

PC45 WPF: Data-centric Applications Using the DataGrid and Ribbon Controls - Samantha Durante, Mark Wilson-Thomas Day 4-Noon

BB15 SQL Server: Database to Data Platform - Road from Server to Devices to the Cloud– David Campbell Day 1

TL08 Offline-Enabled Data Services and Desktop Applications– Pablo Castro Day 3

BB40 Sync Framework: Enterprise Data in the Cloud and on Devices– Liam Cavanaugh Day 2

Page 30: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

Evals & Recordings

Please fill

out your

evaluation for

this session at:

This session will be available as a recording at:

www.microsoftpdc.com

Page 32: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40

© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market

conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

Page 33: Steve Lasker Program Manager Microsoft Corporation blogs.msdn.com/SteveLasker PC40