Wednesday, July 7, 2010

SQL Server Compact 4.0 CTP1 released

The SQL Server Compact team has just released of CTP of version 4.0 of SQL Server Compact Edition.

Ambrish Mishra has a detailed blog about the new features. Here is a short summary:

ASP.NET support

The main feature of version 4.0 is support for using SQL Compact as a file based database engine with ASP.NET websites.

The work done to enable ASP.NET includes:

Higher Reliability – can handle load of starter websites

Setup Enhancements – easier private deployment and a single x64 installer.

Support for ASP.NET – removal of the ASP.NET blocker

Virtual Memory Reduction – allows up to 256 concurrent connections (max) without virtual memory errors.

Medium Trust – enables web hosting with .NET 4.0

It is a part of the recently announced WebMatrix tool for starter websites as a starter database engine, which also includes a tool to design the database used on the website:

image

T-SQL changes

Support for paging queries:

SELECT * FROM Customers ORDER BY [Customer ID] OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY;

ADO.NET Provider enhancements

Seamless Integration with ADO.NET Entity Framework 4.0 (.NET FX 4) – server generated keys and code first support coming soon.

System.Data.SqlServerCe.SqlCeConnection.GetSchema() – allows you to get schema information for use in scripting tools etc.

System.Data.SqlServerCe.SqlCeConnectionStringBuilder() –allows you to build a strongly typed connection string.

Migration

The WebMatrix tools includes a tool to migrate a SQL Compact database to SQL Server 2006/2088/Azure. The tool does not generate a script, but simply creates a new database on the server selected.

image

For migration from SQL Server to SQL Compact, (and script based migration from SQL Compact to SQL Server), you can continue to use my ExportSqlCe tools. I have described the procedure to migrate from SQL Server to SQL Server Compact here. In addition, I have just released SQL Server Compact 4.0 versions of ExportSqlCe and SqlCeCmd.

Visual Studio

Later, a Visual Studio update will enable you to use SQL Server Compact from the Visual Studio Data/Server Explorer, including from Visual Web Developer Express. I assume a similar update for SQL Server Management Studio (SSMS) is not in the cards.

Monday, July 5, 2010

SQL Compact Toolbox – manage Merge Replication subscriptions

In the new release 1.1 of my SQL Compact Toolbox  CodePlex project, it is now possible to manage/test Merge Replication subscriptions in your SQL Compact database file.

image

There is a new “Subscriptions” node. From the nodes context menu, select “New Subscription…”

image

Enter the required parameters, and press Sync. You will then get the tables from the publication in your SQL Compact file.

image

Manage Subscription will load all current parameters (except password), and you can Sync again, or create a C# code sample.

In addition, you can drop the subscription. This will remove any subscription metadata from your SQL Compact database file.

Hope you find this useful, any comments please post here.

Sunday, July 4, 2010

Content overview

My CodePlex SQL Server Compact tools

SQL Server Compact & SQLite Toolbox 4.4 & 4.5 – Visual Guide of new features
SQL Server Compact & SQLite Toolbox 4.3 – Visual Guide of new features
SQL Server Compact & SQLite Toolbox 4.2 – Visual Guide of new features

“SQL Server Compact & SQLite Toolbox” related news


SQLite & SQL Server Compact Toolbox 4.1 – Visual Guide of new features


SQLite Toolbox 4.0 – Visual Guide of Features


SQL Server Compact Toolbox 3.7.3 – Visual Guide of new features


SQL Server Compact Toolbox 3.7.2–Visual Guide of new features


SQL Server Compact Toolbox 3.7.1–Visual Guide of new features


SQL Server Compact Toolbox 3.7–Visual Guide of new features


Document your SQL Server database with free tools: SQL Server Compact Toolbox and DB>Doc
SQL Server Compact Toolbox 3.6–Visual Guide of new features
SQL Server Compact Toolbox 3.4–Visual Guide of new features
SQL Server Compact Toolbox 3.3–Visual Guide of new features
Some SQL Server Compact Toolbox usage graphs
SQL Server Compact Toolbox 3.2–Visual Guide of new features
SQL Server Compact Merge Replication Library alpha released
SQL Server Compact Toolbox 3.1.1 with support for Windows Phone 8 and VS 2012 released
SQL Server Compact Toolbox 3.1–Visual Guide of new features
SQL Server Compact Toolbox 3.0–Visual Guide of new features
SQL Server Compact Toolbox hits 100.000 downloads–new release planned
Migrating databases between SQL Server and SQL Server Compact
SQL Server Compact Toolbox 2.6–Visual Guide of new features
SQL Server Compact Toolbox 2.5–Visual Guide of new features
SQL Server Compact Toolbox available for Visual Studio 11

SQL Server Compact Toolbox 2.4–Visual Guide of new features

SqlCeBulkCopy, a library for fast SQL Server Compact INSERTS released
SQL Server Compact Toolbox 2.3–Visual Guide of new features
SQL Server Compact Toolbox 2.2–Visual Guide of new features
SQL Server Compact ASP.NET Membership, Role and Profile Provider version 2.1 now available
SQL Server Compact Toolbox standalone - including all managed DLLs in a single .exe
New release of Scripting Library and command line utilities–with Schema Diff and DGML from command line
SQL Server Compact Toolbox 2.1–Visual Guide of new features
SQL Server Compact Toolbox 2.0–Visual Guide of new features
New release of ExportSqlCe SSMS add-in and command line utilities–Script to SQL Azure

SQL Server Compact Toolbox add-in now supports version 4.0 databases

SQL Server Compact 4.0 ASP.NET Membership provider

SQL Server Compact version detector

How to Migrate/Downsize a SQL Server database to SQL Server Compact 4.0 (and 3.5)

SQL Server Compact 3.5 Toolbox updated

“SQL Compact Toolbox” – manage merge replication subscriptions

 “SQL Compact Toolbox” Visual Studio 2010 add-in be...

Version 3 of ExportSqlCE now available

SQL Server Compact Bulk Insert Library

Script SQL Server Compact tables in Management Stu...

SqlCeCmd tutorial part two – Creating database obj...

SqlCeCmd tutorial part one – Managing database fil...

SqlCeCmd tutorial part three – query options

Using ExportSQLCE from Visual Studio

Entity Framework Core

Getting started with the SQL Server Compact and other providers for Entity Framework 7 beta 6

Getting and building the Entity Framework 7 alpha bits – step by step

Entity Framework ”reboot” – EF7 – Get a sneak peek via TechEd US live stream

Entity Framework 6

A breaking change in Entity Framework 6.1.2 when using EDMX and SQL Server 2008/2005

Entity Framework 6 and SQL Server Compact 4.0 (10) – “Proper” private desktop deployment
Entity Framework 6 and SQL Server Compact (9) –SqlCeFunctions and DbFunctions
Entity Framework 6 & SQL Server Compact (8) –Logging SQL statements
Entity Framework 6 & SQL Server Compact (7) –New features and fixes in version 6.1
Entity Framework 6 & SQL Server Compact (6)–Entity Framework Reverse POCO Code First Generator
Entity Framework 6 (& SQL Server Compact) (5)–Entity Framework 6 extensions
Entity Framework 6 & SQL Server Compact 4.0 (4) - Restoring full EF Tools support in Visual Studio 2013

Entity Framework 6 & SQL Server Compact (3)–Getting started with the SQL Server Compact 3.5 provider (and Merge Replication)

Entity Framework 6 & SQL Server Compact 4 (2)–Easy Private Desktop Deployment

Entity Framework 6 & SQL Server Compact 4 (1)–Workflows and tooling

INSERTing many rows with Entity Framework 6 beta 1 and SQL Server Compact

Fix for Entity Framework poor INSERT performance with SQL Server Compact and server generated keys

Fixing the Entity Framework designer “Generate Database from Model” T4 template

Entity Framework 4.x

Viewing SQL statements created by Entity Framework with SQL Server Compact

Saving images to SQL Server Compact with Entity Framework 4.1 Code First

Using SQL Server Compact 4.0 with WPF DataGrid, Entity Framework 4 and Private deployment (part 1)

Using SQL Server Compact 4.0 with Desktop Private Deployment and a Setup project (MSI) (part 2)

Entity Framework with SQL Server Compact 4.0 and ASP.NET – Dynamic Data, OData, deployment (part two)

Using Entity Framework with SQL Server Compact 4.0 CTP and ASP.NET – tips & tricks (part one)

Solutions to: “Server-generated keys and server-ge...

SQL Compact and Entity Framework woes

Deployment

The trouble with Any CPU–Prefer 32 bit–BadImageFormatException

SQL Server Compact 4 desktop app with simple Private Deployment and LINQ to SQL

Private deployment of SQL Server Compact 3.5 SP2

SQL Server Compact Private Deployment tweaks

SQL Server Compact “Private Deployment” on desktop–an overview

How to detect if the x64 SQL Compact 3.5 SP2 deskt...

Requirements for SQL Compact installations on x64 ...

Running SQL Compact from CD-ROM (read only media) ...

x64 and SQL Compact

Sort order issue when moving sdf files between pla...

SQL Compact internals and T-SQL

SQL Server Compact ADO.NET data access performance – part 1: Overview

SQL Server Compact ADO.NET data access performance – part 2: INSERTs

SQL Server Compact ADO.NET data access performance – part 3: SELECTs

SQL Server Compact 4.0 SP1 hotfix available

SQL Server Compact breaks when upgrading from Windows 8 to Windows 8.1

FAQ: Why is opening my SQL Server Compact database slow?

Scripting image column data for INSERT statements

Useful new topics in SQL Server Compact 4.0 Books Online

Comparison of SQL Server Compact 4, 3.5 SP2 and SQL Server Express 2008 R2

SQL Server Compact 3.5 SP2 downloadable update list

SQL Compact Table Copy/Export samples published

What’s new in SQL Server Compact 3.5 SP2 beta

Dealing with very large SQL Compact database files...

SQL Server 2005 Compact Edition downloadable hotfixes...

SQL Compact 3.5 SP1 downloadable hotfix list

Scripting SQL datetime fields and avoiding localiz...

SQL Compact 3.5 knowledge base articles

Working with Case Sensitive SQL Compact databases

Testing an sdf file for version info

TOP clause now supported

Hidden gem: Rename table

Code snippet of the week

SQL Server Compact Code Snippet of the Week #1 : locate the ROWGUIDCOL column in a table

SQL Server Compact Code Snippet of the Week #2 : locate the IDENTITY column in a table

SQL Server Compact Code Snippet of the Week #3 : locate the rowversion column in a table

SQL Server Compact Code Snippet of the Week #4 : select rows 50 to 60 from a table

SQL Server Compact Code Snippet of the Week #5 : rename a table

SQL Server Compact Code Snippet of the Week #6 : list all user tables in a database

SQL Server Compact Code Snippet of the Week #7 : get the full path to a database file

SQL Server Compact Code Snippet of the Week #8 : script a database to SQLite

SQL Server Compact Code Snippet of the Week #9 : migrate a SQL Compact database to SQL Server

SQL Server Compact Code Snippet of the Week #10 : generate a CREATE TABLE script

SQL Server Compact Code Snippet of the Week #11 : detect if SQL Server Compact is available

SQL Server Compact Code Snippet of the Week #12 : get the SQL Server Compact runtime version

SQL Server Compact Code Snippet of the Week #13 : reseed (reset) an IDENTITY column

SQL Server Compact Code Snippet of the Week #14 : script all data in a table

SQL Server Compact Code Snippet of the Week #15 : flush data to disk immediately 

SQL Server Compact Code Snippet of the Week #16 : detect Entity Framework database type

SQL Server Compact Code Snippet of the Week #17 : using wildcards with a parameterized query

SQL Server Compact Code Snippet of the Week #18 : handling SqlCeExceptions

SQL Server Compact Code Snippet #19 : migrate a SQL Server database to SQL Compact

SQL Server Compact Code Snippet #20 : change database password

Using SQL Server Compact

Visual Studio

Visual Studio 11 beta - Tooling for SQL Server Compact

Analyzing SQL Server Compact queries using Visual Studio 2010 Premium/Ultimate

SQL Server Compact Toolbox standalone - including all managed DLLs in a single .exe

Visual Studio 2010 Service Pack 1 with support for SQL Server Compact 4.0 released

Migrate a SQL Server Compact database to SQL Server using Web Deploy (MSdeploy)

Using SQL Server Compact 4.0 with WPF DataGrid, Entity Framework 4 and Private deployment (part 1)

Using SQL Server Compact 4.0 with Desktop Private Deployment and a Setup project (MSI) (part 2)

Visual Studio Tools for SQL Server Compact 4 now available

Using Entity Framework with SQL Server Compact 4.0 CTP and ASP.NET – tips & tricks (part one)

SQL Compact 4.0 now available as a .zip file

HOW TO: Detect SQL Server Compact version information

HOW TO: Upgrade a version 3.x database file to SQL Server Compact 4.0

How to check the Visual Studio 2010 edition from code

FAQ: Why does my changes not get saved, SQL CE doe...

Diagram database table relationships using DGML, S...

Using the ADO.NET Data Connection dialog in your o...

How to save and retrieve Images using LINQ to SQL ...

Using SQL Compact with Log4net

Two great tutorials

Crystal Reports with SQL Compact

Accessing SQL Compact from SQL Server "Linked Serv...

x64 and SQL Compact

SQL Compact 3.5 - Manage relationships

Windows Phone

Useful Windows Phone advice from Nick Randolph

Windows Phone / SQL Server Compact resources

Populating a Windows Phone “Mango” SQL Server Compact database on desktop

SQL Server Compact Toolbox 2.2–Visual Guide of new features

Windows Phone Local Database tip: Viewing the SQL generated by LINQ to SQL

Windows Phone Local Database tip: Batch INSERT performance

Windows Phone Local Database tip: Exploring INSERT performance–5 power tweaks

Generating a LINQ to SQL DataContext for VS Express for Windows Phone

Windows Phone Local Database tip: Initializing the database

SQL Server Compact Toolbox 2.6.1–Visual Guide of new features

Windows Phone Local Database tip: Exploring multiple UPDATEs and rowversion impact

Windows Phone Local Database tip: Working with encrypted database files

Windows Phone Local Database tip: Exploring DELETE performance and a “Bug Alert”

Generate a Windows Phone 8 Local Database DataContext from an existing database

Windows Mobile

SQL Compact 3.5 OLEDB C++ sample now available

SQL Compact versions on Windows Mobile

New SQL Server Compact training video

ADO.NET Sync Services for Devices sample

SQL Compact version on Windows Mobile 6.5

Mobile Application Pocket Guide v1.1

Intro to Mobile Sync

Windows Mobile platform support

Mobile sample using SQL Compact

SQL Compact Device Deployment

ASP.NET

SQL Server Compact 4.0 under ASP.NET Hosting– common issues

Using Entity Framework with SQL Server Compact 4.0 CTP and ASP.NET – tips & tricks (part one)

Entity Framework with SQL Server Compact 4.0 and ASP.NET – Dynamic Data, OData, deployment (part two)

Getting started with SQL Server Compact 4.0 (no WebMatrix)

ASP Classic

Access SQL Server Compact 4 with ASP Classic and VbScript

VBA (Office)

Tips and tricks for using SQL Server Compact with VB/VBA/VBScript/ASP

Inserting images from VBA

Import SQL Compact data to Excel

OData (WCF Data Services)

WCF Data Services with Windows Phone - bandwidth requirements measured

Entity Framework with SQL Server Compact 4.0 and ASP.NET – Dynamic Data, OData, deployment (part two)

Walkthrough: Expose SQL Compact data to the world ...

Silverlight

Access a local SQL Compact database from Silverlig...

WPF

Using SQL Server Compact 4.0 with WPF DataGrid, Entity Framework 4 and Private deployment (part 1)

Using SQL Server Compact 4.0 with Desktop Private Deployment and a Setup project (MSI) (part 2)

Binding SQL Compact data to WPF in less than 100 l...

LINQ to SQL

Using LINQ to SQL with SQL Server Compact 4.0 (yes, you can!)

How to save and retrieve Images using LINQ to SQL ...

SQL Compact and LINQ to SQL performance advise

LINQ to SQL

 

SQL Server Management Studio

How to clear the list of recently opened SQL Serve...

SQL Server 2008 Management Studio Express

Accessing SQL Compact from SQL Server "Linked Serv...

SQL Compact 3.5 - Manage relationships

PowerShell

Using PowerShell to manage SQL Server Compact database files

F#

HOW TO: Connect to SQL Server Compact from F#

CodeSmith

Getting started with a CodeSmith nettiers data acc...

Merge Replication

Shop Talk” with Eric Sink, Zumero for SQL Server founderShop Talk” with Eric Sink, Zumero for SQL Server founder
An alternative to Merge Replication with SQL Server and SQL Server Compact – Zumero for SQL Server
Merge Replication with SQL Server Compact 3.5 SP2 and SQL Server 2014 and 2012

SQL Server Compact 3.5 SP2 now supports Merge Replication with SQL Server 2012

Snapshot Synchronization with SQL Server Compact 4.0

Walkthrough: Configuring the Merge Replication Age...

Recent Synchronization and Replication advice from...

IIS 7.5 (Windows Server 2008 R2) and SQL Compact i...

Is RDA (Remote Data Access) still relevant

SQL Compact Merge Replication “bible” updated

Merge replication performance tips

Merge Replication and ISA Server

Intro to Mobile Sync

SQL Compact 3.5 client agent logging

Versions...versions

Sync Framework

Sync Framework news roundup

Recent Synchronization and Replication advice from...

2 new Sync Services hotfixes for SQL Compact

Sync SQL Compact with SQL Azure and Oracle

Microsoft Sync Framework 2.0 released to web!

ADO.NET Sync Services for Devices sample

New features in Sync Framework

Recent Sync Framework articles

SQLite

“Database First” with SQLite in a Universal App using the SQLite Toolbox and sqlite-net

Getting started with SQLite in Windows Store / WinRT apps

Exporting SQL Server Compact to SQLite

Other news stories

Using Exceptionless.com for error logging and feature usage tracking with a Visual Studio add-inUsing Exceptionless.com for error logging and feature usage tracking with a Visual Studio add-in

SQL Server Data Tools for Visual Studio – versions, downloads and compatibility

SQL Server - using newsequentialid() as a function, similar to newid()

Primeworks, supplier of tools for SQL Server Compact, is closing, making all products free, open source

Integrating Red Gate SmartAssembly in the SQL Server Compact Toolbox

SQL Server Compact 4.0 SP1 Released To Web

The state and (near) future of SQL Server Compact

SQL Server Compact 4.0 SP1 CTP1 available

SQL Server Compact will be available for developers in upcoming Windows Phone “Mango” update

SQL Server Compact 4.0 released!

SQL Server Compact 4.0 CTP2 released

SQL Server Compact 4.0 news roundup

SQL Compact 4.0 CTP1 released

SQL Server Compact 3.5 SP2 released!

What’s new in SQL Server Compact 3.5 SP2 beta

No SQL Compact on Windows Phone 7?

New KB article about how to remove SQL Compact 3.5...

Interview with SQL Server Compact Program Manager ...

Dynamics Mobile – SQL Compact used in MS Dynamics ...

News from blog land

3rd party tools

SQL Compact 3rd party tools

Books

New book: .NET Compact Framework 3.5 Data Driven Applications

SQL Server Compact Edition books

SQL Compact Merge Replication “bible” updated

Mobile Application Pocket Guide v1.1

Architecture Journal 14

Wednesday, June 23, 2010

Walkthrough: Expose SQL Compact data to the world as an OData feed, and access SQL Compact data from Excel 2010 and Silverlight

The Open Data Protocol (OData) is a Web protocol for querying and updating data.

Currently, SQL Compact data is only available to ADO.NET and OLEDB based Windows client.

Exposing your SQL Compact data as an OData feed allows your data to be consumed by a variety of different client platforms at any location, including:

OData Explorer (Silverlight Application)

PowerPivot for Excel 2010 is a plugin to Excel 2010 that has OData support built-in.

LINQPad is a tool for building OData queries interactively.

Client libraries: Javascript, PHP , Java, Windows Phone 7 Series, iPhone (Objective C), .NET (Including Silverlight)

I will now show you the steps required to expose a SQL Compact database file a an OData feed using Visual Studio 2010, and how to consume this feed from Silverlight and Excel PowerPivot.

Please note that exposing SQL Compact data like this will not scale to 100s of concurrent users.

Step 1: Create the Web Application

In Visual Studio, select File, New, Project…

image

Select Web, ASP.NET Empty Web Application, and click OK.

Step 2: Add the Entity Framework Model

From the Project menu, select Add New Item…

image

Name the model NorthwindModel and click add.

image

Select Generate from Database and click Next.

image

Select an existing Data Connection or create a new one if required, and click Next.

image

“Just say No”

image

Select Tables and click “Pluralize…” – then click Finish.

Step 3: Add the WCF Data Service (OData Service)

Select Project, Add New Item…

image

Select Web, WCF Data Service, and name it “NWService”, then click Add.

Modify the service code (noted in italic):

    public class NwDataService : DataService<NorthwindEntities>
{
// This method is called only once to initialize service-wide policies.
public static void InitializeService(DataServiceConfiguration config)
{
// Give readonly access to all of the entities
config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);


config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;
}
}



Step 4: Modify global.asax to allow SQL Compact access from ASP.NET



SQL Server Compact 3.5 is not currently optimized to serve as a database for Web sites. SQL Server Compact 3.5 can be used with ASP.NET in application scenarios where ASP.NET is used to create SQL Server Compact 3.5 databases for synchronization scenarios.



To change the default behavior, despite the warning above, open global.asax, and modify as follows (in italic):



void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);
}

Step 5: Run your service!




image 




Right click the NwDataService.svc, and select View in Browser:



image



Your OData service is now ready for consumption by any of the clients mentioned above.



Step 6 – test access from various clients



Access the service from Silverlight (installed elevated):



image



Access the service from Excel 2010 PowerPivot:



image

Thursday, June 17, 2010

Walkthrough: Configuring the Merge Replication Agent (Web Synchronization) sqlcesa35.dll (SP2) on Windows 7 x64 and x86 with IIS 7.5

With the recent release of SQL Server Compact 3.5 SP2, installing the Web Synchronization Agent on Windows 7 and Server 2008 R2 has become a lot easier, as I demonstrate below.

Download the latest Server Tools

First, download the latest version of the SQL Compact Server tools for 3.5 SP2.

For x64 systems, the x64 version of the tools is:  SSCEServerTools_x64-ENU.msi

Notice the following on the download page:

  • Prior to installing SQL Server Compact 3.5 SP2 Server Tools, uninstall all earlier versions of SQL Server Compact Server Tools, including, SQL Server Compact 3.5 SP2 Server Tools Beta, SQL Server Compact 3.5 SP1 Server Tools, SQL Server Compact 3.5 Server Tools, SQL Server 2005 Compact Edition Server Tools or SQL Server 2005 Mobile Edition Server Tools by using the Add/Remove Programs in the Control Panel.
  • On Windows Vista SP1, Windows Server 2008, Windows 7 or Windows Server 2008 R2 with IIS 7.0, the IIS 6.0 Compatibility Components need to be installed prior to installing SQL Server Compact 3.5 SP2 Server Tools. For more information about installing the IIS 6.0 Compatibility Components, see IIS 6 Compatibility Components.

    Configure IIS 7.5

    Enable IIS on Windows 7:

    Click Start, click Control Panel, click Programs and Features, and then click Turn Windows features on or off.

    Select the Internet Information Services check box.

    Open Internet Information Services.

    Open World Wide Web Services.

    Open Application Development Features

    Select the ISAPI Extensions check box.

    Open Web Management Tools.

    Open IIS 6.0 Management Compatibility.

    Select the check boxes for IIS 6 Metabase and IIS 6 configuration compatibility and IIS 6 Management Console

    Click OK.

    image

     

    Install the Server Tools

    Install SSCEServerTools_x64-ENU.msi or SSCEServerTools_x86-ENU.msi

    Important steps:

    image

    The checkmarks in this steps reflects the version of the SQL Server Replication components installed on the system, I my case only SQL Server 2008 replication components are installed.

    Otherwise, just click Next, Next…

    Create the publication and configure for SQL Compact subscribers

    Go ahead and do this. See http://msdn.microsoft.com/en-us/library/ms171780(v=SQL.100).aspx

    Configure the agent - run Configure Web Syncronization Wizard

    Run "C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\sync\SQL\ConnWiz.exe" (you can use the shortcut in Start, All Programs, Microsoft SQL Server Compact 3.5).

    Complete the Wizard.

    Test the agent

    Run: http://mypc/ssce35/sscesa35.dll in your browser.

    You may encounter this error:

    image

    If this happens, try to remove the web.config file from your root web folder (c:\inetpub\wwwroot). This worked for me.

    If the test succeeds, you are good to go:

    image

    You can now use SQL Server Management Studio to test your publication, before testing on other machines and devices.

    Create a new SQL Server Compact Database, and run the New Subscription Wizard to test it.

  • Monday, June 7, 2010

    “SQL Compact Toolbox” Visual Studio 2010 add-in beta available

    I have just published the beta of a new Visual Studio (Professional or higher) add-in, that provides a number of useful tools for SQL Compact developers, directly from the Visual Studio environment:

    Scripting of schema and data, ad-hoc query editing and execution, database relationship diagrams, migration/import/export and more features to come in subsequent releases.

    After investigating the difficulty of creating a Visual Studio add-in, I stumbled upon the SQL Azure Explorer add-in on CodePlex. This gave me hope that creating a Visual Studio add-in could actually be done within a finite and limited amount of effort and time. This project showcased how to create a Toolwindow, and hook this up with a treeview complete with context menus and even a SQL free-form editor. The add-in uses the new VSIX package format, which greatly simplifies end-user management of extensions to the Visual Studio IDE

    To start creating your own add-ins, download the Visual Studio 2010 SDK, and go through the walkthrough on MSDN.

    The add-in gets it’s data repository and script generation code on the “API” available in my ExportSqlCe CodePlex project. In the latest source for this project, the “scripting framework” is available a a single DLL file, SqlCeScripting.dll.

    The add-in bases it’s SQL Server Compact database connections on the Data Connections that you have defined in the Server Explorer. Below is the code to return a list of SQL Server Compact Data Connection names and related connection strings, based on the connections in Server Explorer:

    using Microsoft.VisualStudio.Data;
    using Microsoft.VisualStudio.Data.AdoDotNet;
    using Microsoft.VisualStudio.Data.Interop;



    internal static Dictionary<string, string> GetDataConnections(SqlCe35ToolboxPackage package)
    {
    // http://www.mztools.com/articles/2007/MZ2007018.aspx
    Dictionary<string, string> databaseList = new Dictionary<string, string>();

    var objIVsDataConnectionsService = package.GetServiceHelper(typeof(IVsDataConnectionsService)) as IVsDataConnectionsService;
    var objIVsDataConnectionManager = package.GetServiceHelper(typeof(IVsDataConnectionManager)) as IVsDataConnectionManager;
    if (objIVsDataConnectionsService != null)
    {
    for (int i = 0; i < objIVsDataConnectionsService.Count; i++)
    {
    var objProviderGuid = objIVsDataConnectionsService.GetProvider(i);
    if (objProviderGuid == package.SqlCompact35Provider)
    {
    var sConnectionName = objIVsDataConnectionsService.GetConnectionName(i);
    var sConnectionString = objIVsDataConnectionsService.GetConnectionString(i);
    var objIVsDataConnection = objIVsDataConnectionManager.GetDataConnection(objProviderGuid, sConnectionString, true);
    var conn = (DataConnection)objIVsDataConnection;
    var adoConn = (AdoDotNetConnectionSupport)conn.ConnectionSupport;
    //TODO test for Mobile Connection (using Microsoft.SqlServerCe.Client)
    //Hack to get the underlying connection string including password
    var ceconn = (System.Data.Common.DbConnection)adoConn.ProviderObject;
    databaseList.Add(ceconn.ConnectionString, sConnectionName);
    }
    }
    }
    return databaseList;
    }

    //In the package class:


    public object GetServiceHelper(Type type)
    {
    return GetService(type);
    }



    In addition to the script related features, the add-in allows you to create DGML documents, that visualize the table relationships of your database (see sample in my earlier blog post).



    The following code shows how to open the DGML file from add-in code:



    var dte = package.GetServiceHelper(typeof(EnvDTE.DTE)) as EnvDTE.DTE;


    using (IRepository repository = new DBRepository(databaseInfo.Connectionstring))
    {
    Generator generator = new Generator(repository, fileName);
    generator.GenerateSchemaGraph();
    dte.ItemOperations.OpenFile(fileName);
    dte.ActiveDocument.Activate();
    }


    Here are a few screenshots:



     



    toolbox2



    The table context menu, and the simple query editor.



     



    toolbox1



    The database context menu.



     



    TOOLBOX3



    The root context menu, with SQL Server related menu items.



    Please try out the beta, and provide feedback of any kind.

    Wednesday, June 2, 2010

    SQL Compact Table Copy/Export samples published

    João Paulo Figueira has published a couple of useful sample apps (this time in managed code!) on his new “SmilingSmith” blog:

    SQL Compact table copy

    How do you make a copy of a SQL Compact table? Version 3.5 does not support the SELECT INTO command that allows you to easily do just that. Instead, it provides the INSERT INTO SELECT FROM command that allows you to copy existing table data into another existing table. So we are only missing one part: how to create a replica of the existing table structure.

    SQL Compact table export

    This is a very simple variation on my last blog post: instead of copying the table to the same database, you can now copy it to another database (although with the same table name, but you can easily change that).

    Enjoy!