19
virtual techdays INDIA 18-20 august 2010 Building ASP.NET applications using SQL Server Compact Chaitanya Solapurkar Partner Technical Consultant, Microsoft Global Partner Services

Virtual techdays INDIA │ 18-20 august 2010 Building ASP.NET applications using SQL Server Compact Chaitanya Solapurkar │ Partner Technical Consultant,

Embed Size (px)

Citation preview

virtual techdaysINDIA │ 18-20 august 2010

Building ASP.NET applications using SQL Server Compact Chaitanya Solapurkar │Partner Technical Consultant, Microsoft Global Partner Services

Introduction to SQL Server Compact What is it? Scenarios Demonstration of creating and working with a SQL Server Compact Database

SQL Server Compact and ASP.NET What’s new in SQL Server Compact 4.0? Demonstration of using SQL Server Compact in ASP.NET application

Additional Features and Considerations Getting Connected Accessing Data Deployment

virtual techdaysINDIA │ 18-20 august 2010

S E S S I O N A G E N D A

3

Notes (hidden)

virtual techdaysINDIA │ 18-20 august 2010

Clients Servers CloudSynchronizing data from the point of activity to the data center

SQL Server

virtual techdaysINDIA │ 18-20 august 2010

SQL Server Compact

• Very small (~2 MB) embedded, in-proc database• Nice subset of SQL Server types and SQL dialect• Enables embedded, private, non-admin deployment

What it is

• Mobile, embedded devices, desktop, starter websites• Windows Vista/7, Media Center PC, MSN Client,

ZUNE, Windows Media Player, …• Default local/client database offering in VS 2010

Where it’s deployed

• Local online / offline cache• Local, stand alone application database• Persistent data manager for in-memory database• Structured document format for custom apps

Scenarios

User Code within the Database Stored Procs User Defined Functions

CLR within the database Out of proc

If the hosting app isn’t running, the database isn’t running Out of proc achieved through developer defined Windows Service

Multiple User Roles Application will manage security rights to the database

virtual techdaysINDIA │ 18-20 august 2010

SQL Server Compact

Does not Target

virtual techdaysINDIA │ 18-20 august 2010

Evolution of SQL Server Compact‘06

SQL Server Compact

3.1

‘01

SQL CE 1.0

‘05

SQL Server Compact

3.5

‘07

Embedded Database for devices – eVC, eVB

Enabling synchronization with Sync Services for ADO.NET (Sync FX)

‘03

SQL CE 2.0

.NET Compact Framework Enabled

Adds Tablet PC to Windows Mobile supported OS’sSQL

Server Mobile 3.0

Unlocked for full desktop usage

SQL Server Compact 3.5 SP1 64-bit support, case-sensitive DB

‘08 ‘10

SQL Server Compact 3.5 SP2

New designers & API

SQL Server Compact 4.0 CTP1

Starter websites

virtual techdaysINDIA │ 18-20 august 2010

DEMO: Creating SQL Server Compact Database

Support for ASP.NET Virtual Memory Reduction Higher Reliability Encryption Algorithm Update Medium Trust Support for Paging Queries Deployment Enhancements Integration with ADO.NET EF 4.0*

virtual techdaysINDIA │ 18-20 august 2010

SQL Server Compact and ASP.NET

What’s new in SQL Server Compact 4.0?

Small size, easy to download and no setup configuration needed to install End-to-end development and deployment experience in Visual Studio Easily deployed using xcopy (private deployment) Embedded in the application and no process overhead Supports multiple read and write connections to the database Seamless migration of schema and data to SQL Server Fully functional embedded database with support for indexes, referential

integrity constraints etc. Works in medium trust Tuned for stress and performance for website load

virtual techdaysINDIA │ 18-20 august 2010

SQL Server Compact and ASP.NET

Advantages of Compact in ASP.NET

virtual techdaysINDIA │ 18-20 august 2010

SQL Server Compact and ASP.NET

• Server Explorer• Query Designer• Transact-SQL Editor

Stand-alone designers (not tied to any project)

• Dataset Configuration, Entity Framework• Web Forms• Drag and drop of SQL Compact tables on Web Forms

Project based code generating designers

• Click Once• Web (MS) deployApplication deployment designers

• Project upgrade ,and add new or an existing Local Database• New item template for Compact in Web projects• Add SDF file in App_Data

Other project based miscellaneous designers

• Paid VS SKUs: Pro, Premium, Ultimate• Free: C# Express, VB Express and Visual Web Developer ExpressVS SKU support

Tooling in Visual Studio

virtual techdaysINDIA │ 18-20 august 2010

DEMO: ASP.NET and SQL Server Compact 4.0

SqlCeConnectionString… File path Specifies password And options e.g. Encryption Mode, Max Database Size, Mode(R/W), Autoshrink

Use |DataDirectory| macro To resolve obfuscated .SDF database file location

Use “Max database size” for larger databases Defaults to 128MB for devices and 256 MB for desktop

virtual techdaysINDIA │ 18-20 august 2010

SQL Server Compact

Getting Connected

ADO.NET Entity Framework Create database using code first Support for server generated keys ADO.NET EF CTP4 available for download

Paging queries T-SQL syntax added for OFFSET and FETCH

Typed DataSets & TableAdapters SqlCeResultset – Scrollable & Updateable Cursors

virtual techdaysINDIA │ 18-20 august 2010

SQL Server Compact

Accessing Data

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 X64 Folder Name based off:

Copy the DLLs from the private folder

virtual techdaysINDIA │ 18-20 august 2010

SQL Server Compact

Deployment

Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE")

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 2010 WebMatrix Beta

It provides for seamless migration of schema and data to SQL Server

virtual techdaysINDIA │ 18-20 august 2010

Summary

SQL Server Compact

virtual techdaysINDIA │ 18-20 august 2010

RESOURCES

SQL Server Compact Team Blog http://blogs.msdn.com/b/sqlservercompact/ Latest updates from the SQL Server Compact Team and also some tips and tricks.

SQL Server Compact 4.0 Community Technology Preview http://bit.ly/sqlce4ctp Download of SQL Server Compact 4.0 CTP

SQL Compact Toolbox http://sqlcetoolbox.codeplex.com/ GUI Tool to work with SQL Compact 4.0 CTP

Everything SQL Server Compact http://erikej.blogspot.com/ Blog with updates and tips on SQL Server Compact

virtual techdaysINDIA │ 18-20 august 2010

RELATED CONTENT

Data Driven – Master/Details Business Forms Amar Nityananda 19th August 2010, 3:00pm - 4:00pm

ASP.NET 4.0 Core Runtime Enhancements Sundararajan S 19th August 2010, 4:15pm - 5:15pm

Data-Tier Application in Visual Studio 2010 Abhishek Kala 19th August 2010, 4:15pm - 5:15pm

virtual techdaysTHANKS│18-20 august 2010

[email protected]