Quantcast
Channel: Microsoft's Embedded Database - SQL Server Compact - Team Blog

Can’t find P/Invoke DLL sqlcemeNN.dll

$
0
0

I know this is very annoying, uninformative, directionless…blah blah… error.   And, kindly pardon me for blogging about this error very lately.   Better late than never and here it goes.

 

What are the actual errors?

1) Can't find P/Invoke DLL sqlceme30.dll

2) Can't find P/Invoke DLL sqlceme35.dll

3) Can't find P/Invoke DLL sqlceme40.dll

 

What exactly this error means?

When a managed assembly (In our case, System.Data.SqlServerCe.dll) is trying to P/Invoke a method on to a native DLL (In our case, sqlcemeNN.dll; where NN stands for version of product 30, 35 …etc), system has failed to find the DLL to load and invoke the method.

 

When do we get this error?

We get this error when system cannot find the DLL in the system path, or current process executable path.

 

How can one land in this error?  What are the probable workarounds or fixes?

There are multiple cases and some of the well known ones are given below:

1)      Prior to .NET CF 2.0 SP2, there is no concept of GAC on storage card.  And, if you have installed SQL CE Cab on storage card with .NET CF 2.0 RTM/SP1 on device, our native DLLs end up on storage card and the GAC on the main memory.   Hence, managed assembly will fail when P/Invoking above method

a.       Please use .NET CF SP2 and above

b.      Please install the cabs on main memory

c.       Please move to SQL CE 3.0 SP2/3.1 and above

 

2)      You are developing the application for smart devices (Windows CE OS based) and using Visual Studio Auto Deployment (F5) feature.  And, VS has failed to map the System.Data.SqlServerCe.dll to the right set of cabs to install and just deployed the System.Data.SqlServerCe.dll alone (Note: No error is thrown).  In this case, the native DLLs are not deployed.

a.       Fix the auto-deployment issues (Don’t ask me how L)

b.       Remove and add the reference to System.Data.SqlServerCe.  This is because, VS IDE stores assembly identity in the project file.  Since we have changed the assembly version in SQL CE v3.5 SP1, removing and adding updates the solution to host the right assembly version

c.

     
Manually copy and install the SQL CE Cabs (all the 3 cabs).  They are located under:

%VisualStudioInstallRoot%\SmartDevices\SDK\SQL Server\Mobile\v3.0\<platform>\<processor>

OR

%ProgramFiles%\Microsoft SQL Server Compact Edition\<version>\Devices\<platform>\<processor>

3)   System has failed to load the sqlcemeNN.dll.  To find more details on why system might have failed to load a module is discussed in my previous blog post.

4)   If your machine is a 64-bit box, you might have been got trapped into default target platform 'Any CPU' trap, please set the target platform as 'x86'.  Need more details, please visit ErikEJ's blog post.

5)

    
In all other cases, please move to SQL CE 3.0 SP2/3.1 and above.  If possible make sure HKLM\Software\Microsoft\Microsoft SQL Server Compact Edition\<Version>\NativeDir registry points to the directory where our native DLLs are installed.  Please consider the WoW registry if running in WoW mode.

 

Thanks,

Laxmi Narsimha Rao ORUGANTI

 

[Update: Edited Actual Errors section to see if it helps in catching Live/Google's eye]

[Update: Added 64-bit box story and also a reference to ErikEJ's blog post]


"Houston, we got some problem..." and "Houston, we got a problem..." - notice a difference?

$
0
0

So you have run into a problem - how to efficiently report this:

System configuration:

  • On a Desktop/Server, Run Winver from Start -> Run.
  • On a Pocket PC, Start -> Settings -> About
  • On a Smart Phone, a bit more steps - start -> Settings -> More ->About

Give us all the details you see here.

SQL CE Version:

  • Applies if you had installed SQL CE by various means <VS / SSMS etc.>
  • Search for the sqlcese*.dll, right click it and give us the version in version tab.

A detailed description of what you are trying to do:

  • Include all details like whether you are using Managed /Native code, single/multi-process and a sample code
  • A small repro of the error you are getting would be great! <In case of corrupt databases, the corrupt database>

A Dump file if the process has crashed / hung:

  • On a PC, install this wonderful tool - UserDump.exe from http://support.microsoft.com/kb/241215. This tool installs a control panel entry - click this and register your application's name on this. Next time you get a crash in that app, you will get a dump file in the location you specified. Neat isn't it?
    • In case of a hang, use the same tool above to assign a hotkey and dump the process's current state.

A word of caution, this crash dump file can be pretty big - so ensure you have enough disk space.

  • On a mobile device, this gets a bit trickier. If you are using Windows CE 5.0+ version, and if you are lucky enough to have an OEM vendor who has enabled Windows Error Reporting, you can get a dump. Read this wonderful article at http://windowsfordevices.com/articles/AT7568439504.html by Abraham Kcholi and Gad Meir.
  • For older devices <Win CE 4.2 and so on>, contact us with the program and the problem, and we will handle it case by case.

P.S: No, don't upload all the attachments on to the forums:), but keep them handy. The moment we start looking at this, we will be asking for these.

P.S.2: First post here - w00t! I am a developer in the engine team of SQL CE and I guess you will see me here time and again!

 

Nandri!

Subu Subramanian.

There can be hope only for a society which acts as one big family, not as many separate ones. - Anwar el Sadat 

 

Connectivity Cross Version Compatibility (SQL Server Compact 3.5)

$
0
0

Connectivity Cross Version Compatibility

 

This blog post explains the Merge Replication connectivity cross version compatibility scenarios for the SQL Server Compact 3.5 release. For more information about the connectivity cross version compatibility scenarios in SQL Server Compact 3.1, see SQL Server Compact 3.1 Connectivity Tools.

 

This post is not applicable/refer-to Sync Services for ADO.NET.  Please refer to this post by Mr. Steve Lasker to know the differences between Sync Services for ADO.NET and Merge Replication.

 

 

Product Version Information:

The following table demonstrates the product names and code names used throughout this blog post.

 

Version

Product Official Name(s)

Product Codename

Nickname

Client 2.0

SQL Server 2000 for Windows CE

SQL Server Compact 2.0

<None>

SQL CE 2.0

Client 3.0

SQL Server 2005 Mobile Edition

SQL Server Compact 3.0

<None>

SQL CE 3.0

Client 3.1

SQL Server 2005 Compact Edition

SQL Server Compact 3.1

<None>

SQL CE 3.1

Client 3.5

SQL Server Compact 3.5

<None>

SQL CE 3.5

Server 8.0

SQL Server 2000

Shiloh

SQL Server 8.0

Server 9.0

SQL Server 2005

Yukon

SQL Server 9.0

Server 10.0

SQL Server 2008

Katmai

SQL Server 10.0

 

Summary:

 

1)    SQL Server Compact 3.5 can synchronize with only SQL Server 2005 not with SQL Server 2000.

2)    SQL Server Compact 3.5 Server Tools package enables synchronization between SQL Server Compact client versions 3.0, 3.1, and 3.5 and SQL Server 2005 through SQL Server Compact3.5 IIS components.

3)    SQL Server Compact 3.5 SP1 can synchronize with both SQL Server 2005 and SQL Server 2008. 

4)    SQL Server Compact 3.5 SP1 Server Tools package enables synchronization between SQL Server Compact client versions 3.0, 3.1, 3.5 and SQL Server 2008 through SQL Server Compact 3.5 SP1 IIS components.

 

 

Server Tools Release Plan:

Our release plan for server tools package is as follows: In Phase1, we are releasing SQL Server Compact 3.5 Server Tools package for SQL Server 2005 (Yukon) and SQL Server Compact 3.5 SP1 Beta Server Tools package for SQL Server 2008 (Katmai). In Phase2, we will release the SQL Server Compact 3.5 SP1 Server Tools package for both SQL Server 2005 (Yukon) and SQL Server 2008 (Katmai). This new package will replace the Phase 1 packages.

 

Important:

This blog post does not describe the following deployment scenarios:

1)    Upgrading clients from SQL Server Compact version 2.0 to versions 3.0 and 3.1

2)    Upgrading from SQL Server 2000 to SQL Server 2005

3)    Mixed installations including SQL Server compact client versions 2.0, 3.0,  3.1  and SQL Server or publisher versions SQL Server 2000 (8.0), and SQL Server 2005 (9.0)

For more information about these deployment scenarios, please see SQL Server Compact 3.1 Connectivity Tools documentation.

 

 General Information for Deployment:

1)    You can always install SQL Server Compact client versions 3.0 and 3.5 side-by-side.

2)    The version of SQL Server IIS components must be equal to or lesser than the version of  SQL Server Publisher.

3)    You can install the SQL Server IIS components side-by-side . When installing side-by-side, the SQL Server IIS components should be in two different physical and virtual directories.

4)    SQL Server IIS components and SQL Server Compact IIS components reside in IIS server.

5)    You can install the SQL Server IIS components from the SQL Server Installation CD. In feature selection page, choose Shared Features, and then Client Tools to install the SQL Server IIS components.

 

The new rules that apply only to SQL Server Compact v3.x:

1)    The version of SQL Server Compact v3.x client components must be equal to or lesser than the version of SQL Server Compact v3.x IIS components. In other words, SQL Server Compact 3.0 client can connect to 3.0, 3.1, 3.5 IIS components. SQL Server Compact 3.1 client can connect to 3.1, 3.5 IIS components. SQL Server Compact 3.5 client can connect to 3.5 IIS components.

2)    SQL Server Compact 3.x IIS Components are not side-by-side installable.

1     Cross Version Compatibility

1.1       Cross Version Compatibility Support Matrix

 

The following table provides the cross version compatibility support for each different type of deployment scenario. The table includes:

·         “Dx”: An identifier for each different scenario.

·         “Existing Support”: A deployment that is already supported. For more information, see SQL Server Compact 3.1 Connectivity Tools.

·         “New Support”: A new supported deployment. This new deployment is explained in this blog post later.

·         “Pending Support”:  Specifies that SQL Server Compact 3.5 RTM does not support synchronization to SQL Server 2008 but this support will be enabled in SQL Server Compact 3.5 SP1.

 

Deployment Scenario No

SQL Server Compact

Client Version

SQL Server Publisher Version

Supported

(Yes/No)

Notes

D1

2.0

N/A

N/A

N/A

D2

3.0/3.1

SQL Server 2000 SP3a or later

Yes

Existing Support

D3

3.0/3.1

SQL Server 2005

Yes

Existing Support

D4

3.0/3.1

SQL Server 2008

Yes

New Support

D5

3.5 RTM or later

SQL Server 2000

No

Retired/Deprecated

D6

3.5 RTM or later

SQL Server 2005

Yes

New Support

D7

3.5 RTM

SQL Server 2008

No

Pending Support

D8

3.5 SP1 or later

SQL Server 2008

Yes

New Support

 

 

 

SQL Server  version--à

SQL Server 2000

SQL Server 2005

SQL Server 2008

SQL Server Compact Version

2.0

Old

Old

Not Supported

3.0/3.1

Old

Old

New

3.5 RTM

Not Supported

New

Not Supported

3.5 SP1 or later

Not Supported

New

New

 

1.2       Compatibility with SQL Server and IIS components

 

The following table summarizes the compatibility with SQL Server Compact, SQL Server and server IIS components. For more information, see Section 2 Deployment Scenarios.  This section requires thorough understanding of Merge Replication deployment.

 

SQL Server  Compact

Client Version

SQL Server Compact IIS Components Version

SQL Server

IIS Components Version

SQL Server

Publisher Version

2.0

N/A

N/A

N/A

3.0/3.1

3.1

8.0

8.0

3.0/3.1

3.1

9.0

9.0

3.0/3.1

3.5 SP1+

10.0

10.0

3.5 RTM+

N/A

N/A

8.0

3.5 RTM+

3.5 RTM+

9.0

9.0

3.5 RTM

N/A

N/A

10.0

3.5 SP1+

3.5 SP1+

10.0

10.0

 

 


 

2     Deployment Scenarios

This section describes how to upgrade the existing deployment and how to set up a new deployment. In addition, this section also describes how to setup a deployment of the mixed subscribers.

The mixed subscribers represent the SQL Server Compact clients that are of different versions. For example, a single deployment might have different versions of SQL Server Compact clients connecting to the same SQL Server Publisher through either same or different IIS servers. In this case, these SQL Server Compact clients are called as mixed subscribers. For more information on how to configure the IIS Server Environment, see http://msdn2.microsoft.com/en-us/library/ms172441(SQL.100).aspx.

 

Note: SQL Server Compact includes a connectivity wizard, "Configure Web Synchronization Wizard", which helps you configure a virtual directory in Internet Information Services (IIS).  Whenever a virtual directory URL is changed, you need to update the Virtual Directory Information to refer to a new URL. For more information about how to do this, see http://msdn2.microsoft.com/en-us/library/ms172450(SQL.100).aspx and http://msdn2.microsoft.com/en-us/library/ms171862(SQL.100).aspx. You also need to update the clients to point to this new URL. 

 

2.1       New Deployment

 

This section describes how to set up a new deployment for the new deployment scenarios introduced with SQL Server Compact 3.5 and/or SQL Server 2008. 

2.1.1  SQL Server Compact 3.5 RTM+ and SQL Server 2005 (D6)

 

1)    Install SQL Server 2005 on a Publisher computer

2)    Install SQL Server Compact  3.5 RTM+ on a client computer

3)    Install SQL Server 2005 IIS Components on IIS server

4)    Install SQL Server Compact 3.5 RTM+ Server Tools Package on IIS server

5)    Configure Web Synchronization with SQL Server Compact 3.5 Server Agent ISAPI

 

2.1.2  SQL Server Compact versions 3.0 or 3.1 and SQL Server 2008 (D4)

 

1)    Install SQL Server 2008 on a Publisher computer

2)    Install SQL Server Compact versions 3.0 and 3.1 on a client computer

3)    Install SQL Server 2008 IIS Components on IIS server

4)    Install SQL Server Compact  3.5 SP1+ Server Tools Package on IIS server

5)    Configure Web Synchronization with SQL Server Compact 3.5 Server Agent ISAPI

 

2.1.3  SQL Server Compact 3.5 SP1+ and SQL Server 2008 (D8)

 

1)    Install SQL Server 2008 on a Publisher computer

2)    Install SQL Server Compact 3.5 SP1+ on a client computer

3)    Install SQL Server 2008 IIS Components on IIS server

4)    Install SQL Server Compact 3.5 SP1+ Server Tools Package on IIS server

5)    Configure Web Synchronization with SQL Server Compact 3.5 Server Agent ISAPI

 

2.2       Upgrading an Existing Deployment (Full)

2.2.1  Server Upgrade Only:  from SQL Server 2000 or 2005 to SQL Server 2008

2.2.1.1   SQL Server Compact version 2.0 clients

 

This scenario is not supported.  In this case, clients must be upgraded along with the server.

2.2.1.2   SQL Server Compact versions 3.0 and 3.1 clients

 

1)    Upgrade SQL Server

2)    Retain SQL Server  versions 3.0 and 3.1 on a client computer

3)    Uninstall SQL Server Compact 3.1 Server Tools Package on IIS server

4)    Optionally uninstall SQL Server 2000/2005 IIS Components on IIS server

5)    Remove the SQL Server Compact 3.1 Server Agent ISAPI Virtual Directories

6)    Install SQL Server 2008 IIS Components on IIS server

7)    Install SQL Server Compact 3.5 SP1+ Server Tools Package on IIS server

8)    Configure Web Synchronization with SQL Server Compact 3.5 Server Agent ISAPI

 

2.2.2  Client Upgrade Only

2.2.2.1   Upgrade from SQL Server Compact 2.0 to SQL Server Compact 3.5

2.2.2.1.1       SQL Server 2000

 

This scenario is not supported. In this case, the server must be upgraded.

2.2.2.1.2       SQL Server 2005

 

1)    Upgrade SQL Server Compact clients

2)    Retain SQL Server on a Server computer

3)    Uninstall SQL Server Compact 3.1 Server Tools Package on IIS server (if any)

4)    Uninstall SQL Server Compact 2.0 Server Tools Package on IIS server

5)    Optionally uninstall SQL Server 2000 IIS Components on IIS server

6)    Install/Retain SQL Server 2005 IIS Components on IIS server

7)    Remove the SQL Server Compact 2.0 Server Agent ISAPI Virtual Directories

8)    Install SQL Server Compact 3.5 RTM+ Server Tools Package on IIS server

9)    Configure Web Synchronization with SQL Server Compact 3.5 Server Agent ISAPI

 

2.2.2.2   Upgrade from SQL Server Compact versions 3.0 and 3.1 to SQL Server Compact 3.5

2.2.2.2.1       SQL Server 2000

 

This scenario is not supported.  In this case, the server must be upgraded along with the clients.

2.2.2.2.2       SQL Server 2005

 

1)    Upgrade SQL Server Compact Clients

2)    Retain SQL Server on a Server computer

3)    Uninstall SQL Server Compact 3.1 Server Tools Package on IIS server

4)    Retain SQL Server 2005 IIS Components on IIS server

5)    Remove the SQL Server Compact 3.1 Server Agent ISAPI Virtual Directories

6)    Install SQL Server Compact 3.5 RTM+ Server Tools Package on IIS server

7)    Configure Web Synchronization with SQL Server Compact 3.5 Server Agent ISAPI

 

2.2.2.2.3       SQL Server 2008

 

This deployment scenario describes an incremental upgrade where servers are upgraded from SQL Server 2000 or 2005 to SQL Server 2008 as described in section 2.2.1.2 above  and then clients are getting upgraded. This deployment scenario might be useful in some cases where you might choose to upgrade the servers first and then the clients.

 

1)    Upgrade SQL Server Compact clients

2)    Retain SQL Server on a Server computer

3)    Uninstall SQL Server Compact 3.1 Server Tools Package on IIS server

4)    Retain SQL Server 2008 IIS Components on IIS server

5)    Remove the SQL Server Compact 3.1 Server Agent ISAPI Virtual Directories

6)    Install SQL Server Compact 3.5 SP+ Server Tools Package on IIS server

7)    Configure Web Synchronization with SQL Server Compact 3.5 Server Agent ISAPI

 

2.2.3  Client and Server Upgrade in Parallel

2.2.3.1   SQL Server Compact Clients: from 2.0 to 3.5, SQL Servers: from 2000 to 2005

 

1)    Upgrade SQL Server Compact clients

2)    Upgrade SQL Server

3)    Uninstall  SQL Server Compact 3.1 Server Tools Package on IIS server (if any)

4)    Uninstall SQL Server Compact 2.0 Server Tools Package on IIS server

5)    Uninstall SQL Server 2000 IIS Components on IIS server (optional)

6)    Remove the SQL Server Compact 2.0 Server Agent ISAPI Virtual Directories

7)    Install SQL Server 2005 IIS Components on IIS server

8)    Install SQL Server Compact 3.5 RTM+ Server Tools Package on IIS server

9)    Configure Web Synchronization with SQL Server Compact 3.5 Server Agent ISAPI

 

2.2.3.2   SQL Server Compact Clients: from 2.0 to 3.5, SQL Servers: from 2000 or 2005 to 2008

 

1)    Upgrade SQL Server Compact clients

2)    Upgrade SQL Server

3)    Uninstall  SQL Server Compact 3.1 Server Tools Package on IIS server (if any)

4)    Uninstall SQL Server Compact 2.0 Server Tools Package on IIS server

5)    Uninstall SQL Server 2000/2005 IIS Components on IIS server (optional)

6)    Remove the SQL Server Compact 2.0 Server Agent ISAPI Virtual Directories

7)    Install SQL Server 2008 IIS Components on IIS server

8)    Install SQL Server Compact 3.5 SP1+ Server Tools Package on IIS server

9)    Configure Web Synchronization with SQL Server Compact 3.5 Server Agent ISAPI

 

 

2.2.3.3   Server Compact Clients: from versions 3.0 or 3.1 to 3.5, SQL Server versions: from 2000 to 2005

 

1)    Upgrade SQL Server Compact clients

2)    Upgrade SQL Server

3)    Uninstall SQL Server Compact 3.1 Server Tools Package on IIS server

4)    Uninstall SQL Server 2000 IIS Components on IIS server (optional)

5)    Remove the SQL Server Compact versions 3.0 or 3.1 Server Agent ISAPI Virtual Directories

6)    Install SQL Server 2005 IIS Components on IIS server

7)    Install SQL Server Compact 3.5 RTM+ Server Tools Package on IIS server

8)    Configure Web Synchronization with SQL Server Compact 3.5 Server Agent ISAPI

 

 

2.2.3.4   Server Compact Clients: from versions 3.0 or 3.1 to 3.5, SQL Server versions: from 2000 or 2005 to 2008

 

 

1)    Upgrade SQL Server Compact clients

2)    Upgrade SQL Server

3)    Uninstall SQL Server Compact 3.1 Server Tools Package on IIS server

4)    Uninstall SQL Server 2000/2005 IIS Components on IIS server (optional)

5)    Remove the SQL Server Compact version 3.0/3.1 Server Agent ISAPI Virtual Directories

6)    Install SQL Server 2008 IIS Components on IIS server

7)    Install SQL Server Compact 3.5 SP1+ Server Tools Package on IIS server

8)    Configure Web Synchronization with SQL Server Compact 3.5 Server Agent ISAPI

 

2.3       Mixed Deployments

 

Mixed deployments might be due to choice or due to an incremental upgrade, etc.  This section describes how to setup IIS server in mixed deployment scenarios and in what cases multiple IIS servers are required. 

 

The scope of mixed subscribers in this section is limited to the SQL Server Compact subscribers of multiple versions. In other words, this section explains only mixed of versions of SQL Server Compact clients. This section does not explain the mixed deployment scenarios including different types of subscribers such as SQL Server Compact subscriber and SQL Express subscribers together.

 

 

 

2.3.1.1   SQL Server Compact Client versions:  2.0, 3.5; SQL Server versions: Any

 

This deployment scenario describes a deployment, which might include SQL Server Compact 2.0 or 3.5 subscribers and any version of SQL Server publishers.

 

SQL Server Compact 2.0 and 3.5 cannot be subscribers to the same publisher even with different publications.  This combination is not supported.  Either SQL Server Compact 2.0 subscribers must be upgraded to SQL Server Compact versions 3.0 or 3.1 or 3.5, or there must be different publishers for different SQL Server Compact clients in the deployments. 

 

If there are different publishers; you should make sure to have different IIS servers configured.  

For more information about how to setup two completely disjoint parallel deployments, please see New Deployment. 

 

2.3.1.2   SQL Server Compact Client versions: 2.0, 3.0 or 3.1; SQL Server versions: Any

 

SQL Server Compact 2.0 cannot be a subscriber to SQL Server 2008; therefore this deployment cannot be a valid mixed deployment. For more information about this kind of mixed deployment, see SQL Server Compact 3.1 Connectivity Tools.

2.3.1.3   SQL Server Compact Client versions: Any; SQL Server versions: 2000, 2008

This deployment scenario describes a deployment, which might include SQL Server Compact 2.0 or 3.0 or 3.1 or 3.5 subscribers and SQL Server 2000 or 2008 publishers.

 

Important: SQL Server Compact 3.5 cannot be a subscriber to SQL Server 2000 publisher.

 

 

 

If there are different publishers and different sets of subscribers, you should make sure to have different IIS servers configured.  In this case, you might need separate set of deployments, such as:

 

·         Subscriber Set1 merge replicates through IIS Server1 with SQL Server1

·         Subscriber Set2 merge replicates through IIS Server2 with SQL Server2

 

Note that this deployment scenario is not a mixed deployment but it is much more similar to the two completely disjoint parallel setups which can be configured as specified in section New Deployment above. 

 

 

 

2.3.1.4   SQL Server Compact client versions: 3.0, 3.1, 3.5; SQL Server versions: 2005, 2008

 

In this deployment scenario, one IIS server can serve all the SQL Server Compact subscribers with or without multiple publishers in the deployment.  Note that SQL Server Compact 3.5 IIS Components can connect to any SQL Server Compact version 3.x client component. Therefore, a single SQL Server Compact 3.5 Server Agent URL can be used by all SQL Server Compact version 3.x Clients. 

 

Note that  when using SQL Server 2008 as a Publisher, the SQL Server Compact 3.5 IIS components must be of version 3.5 SP1 or greater.

 

To setup this kind of mixed deployment, you should follow these steps:

 

1)    Upgrade clients and servers (if necessary)

2)    Uninstall SQL Server Compact 3.1 Server Tools Package on IIS server (if any)

3)    Uninstall  SQL Server Compact 2.0 Server Tools Package on IIS server (if any)

4)    Uninstall SQL Server 2000 IIS Components on IIS server (optional)

5)    Remove the SQL Server Compact 2.0 Server Agent ISAPI Virtual Directories

6)    Remove the SQL Server Compact versions 3.0/3.1 Server Agent ISAPI Virtual Directories

7)    Install/Retain SQL Server 2005 IIS Components on IIS server(if any publisher is SQL Server 2005)

8)    Install/Retain SQL Server 2008 IIS Components on IIS server(if any publisher is SQL Server 2008)

9)    Install SQL Server Compact 3.5 RTM+ Server Tools Package on IIS server(if all publishers are SQL Server 2005)

10) Install SQL Server Compact 3.5 SP1+ Server Tools Package on IIS server(if any publisher is SQL Server 2008)

11) Configure Web Synchronization with SQL Server Compact 3.5 Server Agent ISAPI

 

 

 

You might choose to configure multiple IIS servers for different set of publisher and subscriber combinations. If you do that, this case cannot be a mixed deployment anymore. It would be much similar to two completely disjoint parallel setups which can be configured as specified in section New Deployment above.

 

 

Thanks

SQL Server Compact Release Versions

$
0
0

 

This blog post is meant to give different build version numbers of our SQL Server Compact Releases. This blog post is a living one and gets updated for every release we make.

 

Before getting into the mapping, first you want to know the version you are having.  There are multiple means: 

Registry: HKLM\Software\Microsoft\Microsoft SQL Server Compact Edition\*\DesktopRuntimeVersion

File Properties: Check file properties of some SQL CE DLL and check for "File version" the first line of version tab

 

Product Name

Release Vehicle

Version

SQL Server 2005 Mobile Edition

Visual Studio 2005 RTM

3.0.5206

SQL Server 2005 Mobile Edition

SQL Server 2005 RTM

3.0.5207

SQL Server 2005 Compact Edition

Visual Studio 2005 SP1

3.0.5300

SQL Server 2005 Compact Edition

SQL Server 2005 SP2

3.0.5300

SQL Server 2005 Compact Edition

Download Center

3.0.5300

SQL Server 2005 Compact Edition

Windows Mobile 6.0

3.0.5289

SQL Server Compact 3.5 Beta1

Visual Studio 2008 Beta1

3.5.5339

SQL Server Compact 3.5 Beta2

Visual Studio 2008 Beta2

3.5.5365

SQL Server Compact 3.5 RTM

Visual Studio 2008 RTM

3.5.5386

SQL Server Compact 3.5 RTM

Download Center

3.5.5386

SQL Server Compact 3.5 SP1 Beta

SQL Server 2008 CTP5 OR

SQL Server 2008 Nov07 CTP

3.5.5608

SQL Server Compact 3.5 SP1 Beta for ADO.NET Entity Framework Provider Beta

Download Center

3.5.5626

SQL Server Compact 3.5 SP1 Beta

SQL Server 2008 CTP6 OR

SQL Server 2008 Feb08 CTP

3.5.5626

SQL Server Compact 3.5 SP1 RTM

Visual Studio 2008 SP1 RTM

3.5.5692

SQL Server Compact 3.5 SP1 RTM

SQL Server 2008 RTM

3.5.5692

SQL Server Compact 3.5 SP1 RTM 

with .NET Framework 4 Beta Support

Visual Studio 2010 Beta 1 

3.5.5802 

SQL Server Compact 3.5 SP2 Beta 

Microsoft Visual Studio 2010 and .NET Framework 4 Beta 2

3.5.8044 

SQL Server Compact 3.5 SP2 Beta 

SQL Server Compact 3.5 SP2 Beta for Windows Desktop Web Download

3.5.8049 

SQL Server Compact 3.5 SP2 Release Candidate

Visual Studio 2010 and .NET Framework 4 Release Candidate

3.5.8078 

SQL Server Compact 3.5 SP2 

1. Visual Studio 2010 and .NET Framework 4 RTM

2. SQL Server Compact 3.5 SP2 for Windows Desktop

3.5.8080 

 

 

 

 

 

Update: This information is now available as a KB Article 950550.  The KB article list only the final release versions and not beta/CTP/alpha versions.

 

Thanks,

Laxmi Narsimha Rao ORUGANTI

 

Download available for SQL Server Compact 3.5 SP1 Beta for ADO.Net Entity Framework Beta 3

$
0
0

The SQL Server Compact 3.5 SP1 Beta for ADO.Net Entity Framework Beta 3 is available for download at Microsoft Download Center.

To install SQL Server Compact 3.5 SP1 Beta Release for ADO.NET Entity Framework Beta 3

  1. Install ADO.NET Entity Framework Beta 3 from Microsoft Download Center. You must ensure that the pre-requisites specified on the download page are installed before installing ADO.NET Entity Framework Beta 3.
  2. In Control Panel, double-click Add or Remove Programs. Uninstall SQL Server Compact 3.5 or SQL Server Compact 3.5 SP1 Beta.
  3. Install SQL Server Compact 3.5 SP1 Beta Release for the ADO.NET Entity Framework Beta 3 (SSCERuntime-ENU.msi) from the Microsoft Download Center. Note that administrator rights are required on a computer to install SQL Server Compact 3.5 SP1 Beta Release for ADO.NET Entity Framework Beta 3.

To install ADO.NET Entity Framework Tools December 07 Community Technology Preview (CTP)

  1. Install the ADO.NET Entity Framework Beta 3 and SQL Server Compact 3.5 SP1 Beta Release for the ADO.Net Entity Framework Beta 3 as specified above. Install ADO.NET Entity Framework Tools December 2007 CTP from the Microsoft Download Center. You must ensure that the pre-requisites specified on the download page are installed before installing ADO.NET Entity Framework Tools December 2007 CTP. The CTP installs on a Visual Studio 2008 installation.
  2. Copy the SQL Server Compact 3.5 SP1 Design Tools Beta (SSCEVSTools-ENU.exe) to your computer by clicking on Save or Save this program to disk and after the download is complete install SSCEVSTools-ENU.exe by double-clicking it. Do not install the SSCEVSTools-ENU.exe by clicking on the Run. While running the SSCEVSTools-ENU.exe file, Microsoft.SqlServerCe.Client.dll is extracted to %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE folder. The SSCEVSTools-ENU.exe will create a backup of the existing DLL at the location %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE.

For uninstalling SQL Server Compact 3.5 SP1 Beta refer to the read me.

The steps to create a sample application are as given below:

1.    Start Visual Studio 2008 and create a console project by clicking on the menu item File à New à Project. In the New Project window expand Visual Basic or Visual C#, select Windows and then select Console Application. For the project the .Net Framework version should be .Net Framework 3.5. Name the project as SQLCompactEDMProject. On clicking OK the project is created

2.    To generate the Entity Data Model for the Northwind.sdf, copy the Northwind.sdf from the folder %Program Files%\Microsoft SQL Server Compact Edition\v3.5\Samples to the users folder like C:\Users\<login name>\Documents\Visual Studio 2008\Projects\SQLCompactEDMProject\SQLCompactEDMProject. Select the SQLCompactEDMProject in the Solution Explorer and right-click, point to Add, and then click New Item. Select ADO.NET Entity Data Model in the Templates pane. Enter Northwind.edmx for the model name and click Add. The opening page of the Entity Data Model Wizard is displayed.

3.    Select Generate from database in the Choose Model Contents dialog box and click Next. Click the New Connection button. The Connection Properties dialog box is displayed.

4.    In the Connection Properties dialog click the button Change in the Data Source. In the Change Data Source dialog box select Microsoft SQL Server Compact 3.5 and click OK. Click the radio button My Computer in the Data Source. In the Connection Properties browse to the Northwind.sdf and click OK in the Connection Properties dialog. The Choose Your Data Connection screen in the Entity Data Model Wizard comes up.  

5.    The checkbox in front of Save entity connection settings in App.Config as: will be clicked by default. Change the name in the dialog from Entities to NorthwindEntities. Click Next to continue.

6.    The Choose Your Database Objects dialog box is displayed. By default all the tables in the database are selected and will be included in the EDM. Uncheck the box next to Tables. This deselects all the tables in the database. Expand the Tables node and select the Customers, Orders, and Products tables. Change the  Model Namespace: from Model to NorthwindModel

7.    Click Finish to complete the wizard.

a.    The wizard does the following:

b.    Adds references to the System.Data, System.Data.Entity, System.Core, System.Security, and System.Runtime.Serialization assemblies.

c.    Generates an .edmx file which encapsulates the information from the EDM mapping files.

d.    Creates an App.Config file.

8.    Double click the App.Config file in the Solution Explorer to open it. Change the provider entry from provider=Microsoft.SqlServerCe.Client.3.5 to provider=System.Data.SqlServerCe.3.5

9.    Add an Imports (Visual Basic) or using (C#) statement at the beginning of the file to reference the EDM created from the Northwind database. (The name of the model corresponds to the value of the namespace attribute in your .edmx file).

Visual Basic

Imports SQLCompactEDMProject.NorthwindModel

C#

using NorthwindModel;

10. Add the following code to the Main subroutine (Module1.vb or Program.cs)

Visual Basic

Using db As NorthwindEntities = New NorthwindEntities

Dim customers = From c In db.Customers _

Where c.City = "London" _

Order By c.Company_Name Select c

For Each c As Customers In customers

Console.WriteLine(c.Company_Name)

Next

Console.ReadLine

End Using

C#

using (NorthwindEntities db = new NorthwindEntities())

{

var customers = from c in db.Customers

where c.City == "London"

orderby c.Company_Name

select c;

foreach (Customers c in customers)

{

Console.WriteLine(c.Company_Name);

}

Console.ReadLine ();

}

11. Press CTRL+F5 to run the application. After the results display on the console screen press enter to exit the application

For more information and samples please see the ADO.NET Entity Framework Beta 3 Documentation and ADO.NET Entity Framework Samples

Regards,

 

Ambrish Mishra

Program Manager - SQL Server Compact

My First Entity Application Against SQLCE

$
0
0

Now that SQL Server Compact 3.5 SP1 Beta is released it's time to take the first step, making your first entity application using SQLCE as a backend.

In his previous post, Ambrish gave steps on how to install SQL Server Compact SP1 Beta, along with Ado.Net Entity Framework Beta 3 and writing a small program to query the Northwind Database via LINQ.

In this post, I will briefly walk you through what Entity Framework Beta 3 has offer to, and how can we leverage it to write different types of entity queries against SQL Server Compact.

Going by EF Definition at: http://msdn2.microsoft.com/en-us/library/bb399572.aspx

The most unique selling point in my opinion becomes the part where you can run the same program/application against any backend (assuming the database schema is same), you have to just modify connection strings. Let's say even if the schema is little different, you can get that easily fixed in your metadata files, and boom, your app works.

I am including few screenshots which will guide you on how to go by making your own application and the complete program.

Please do read the previous post (by Ambrish) carefully as I will assume that you are done with the setup and we are ready to go. For those who could get things set up I am posting some screen shots to help you with that.

First step is to include an Ado.Net Entity Data Model into your project, give it a name that makes sense, I gave it SSCNorthwind.

Add Ado.NET Entity Data Model

 

Generate Model From DB

 

The screenshot below, shows the database file that we selected, its connection string that will go into your App.config file and also the name you want to give it. For simplicity I chose NorthwindEntities.

Choosing the Connection and Saving App.Config

 

The screenshot below shows you how to include the database file that you placed in your project root for generating data model.

Select Northwind DB from your samples directory

 

The wizard below allows you to choose the tables that you want to be part of entity set, as SQL CE does not support stored procedures and views as of now, we will ignore those two options.

Choose the Tables you want. SP and Views are not supported for SQLCE

 

The red box in below shows the change that we have to make in App.Config to make this working J i.e. renaming the provider:

provider=Microsoft.SqlServerCe.Client.3.5 to provider=System.Data.SqlServerCe.3.5

This is being fixed, so in RTM version you won't have to do this manual step.

You can see that the name of Entity set is NortwindEntities, so whenever we make connection to this set, the connection string provided in App.Config file will be used.

Before:

Before

After:

After

This is how the solution explorer should look now:

Solution

If you face any error while adding Northwind.sdf file into your project, just ignore it for now.

I have tried to include some comments in my program below to help you understand what's going on.

Points to notice:

To connect to a Database using an Entity Connection, you can do it in two ways.

  1. First way is to specify your own connection string, like I have done at the start of program. Using that you can directly create an Entity Connection and work in the same way you used to work with SqlCeConnection and SqlCeCommand. That way can be seen in ESQL Query region.
  2. The second approach is using Contexts or what we call here NorthwindEntities, (remember at top we renamed Entities to this for better understanding). For using context, you can do that in multiple ways
  • First, you can give a connection string and it will create the set.
  • Second, you can also first create an Entity Connection like above and then pass it on the NorthwindEntities, which is what I have done in Object Query section.
  • And the last approach for which we created App.Config in first place. You don't specify anything at all, the entity set (NorthwindEntities) picks up your connection string from App.Config and creates a connection. LINQ to Entites Query section is done using this approach.

Program (Contents of Program.cs):

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Data.EntityClient;

using NorthwindModel;

using System.Data;

 

namespace MyFirstEntityApplicationForSSC

{

    class Program

    {

       

        #region Static Declarations

 

        //SQLCE Connection string for the sample database Northwind.sdf

        static string _sqlCeConnnectionString = @"Data Source = Northwind.sdf";

       

        //entityConnectionString: If your metadata(CSDL, SSDL and MSL, or in this case EDMX) files lie in the same place as application, you can use "."

        static string _entityConnectionString =

            String.Format(@"metadata=.;Provider=System.Data.SqlServerCe.3.5;provider connection string=""{0}""", _sqlCeConnnectionString);

 

        //New Values that you might want to use for changing the data

        static string _newFirstName = "AGENT";

        static string _newLastName = "SMITH";

        static string _newCountry = "MATRIX";

 

        #endregion Static Declarations

 

        #region Main

        /// <summary>

        /// MAIN: It calls the three different functions for following type of queries

        /// Description in layman language

        ///

        /// ESQL - This takes you back to old .Net 2.0 days where you used to set T-SQL statements and execute them, just that it here works on entities now instead of tables

        /// Example Demonstrates: Simple Select Query using Entity SQL.

        ///

        /// Object Query - Working on Data Objects was never so easy. This type of queries give you the power to work on data objects and most of all intellisense helps with things you can do

        /// Example Demonstrates: Query and Updation of data and then Re-Querying

        ///

        /// LINQ to Enity - LINQ means Language Integrated Query. This is a new and powerful way of writing queries that are checked for syntax at compile time itself. So, chances of failing in query logic at runtime become minimal

        /// Example Demostrates: Query the data using default settings for connection in App.Config that was configured via EF Designer.

        /// </summary>

        /// <param name="args"></param>

        static void Main(string[] args)

        {

            Console.WriteLine("SQL CE Northwind Entity App:");

            try

            {

                EntityConnection entityConnection = new EntityConnection(_entityConnectionString); //Creating a new entity connection using the entity connection string

                entityConnection.Open();

 

                Console.WriteLine("\nESQL Query:");

                ESQL_Query(entityConnection); //This does not use context, it's a simple esql command execution

 

                Console.WriteLine("\nLINQ To Entity Query:");

                LINQ_To_Entity_Query(); //This will make a new connection using the connection string in the App.Config file

 

                Console.WriteLine("\nObject Query:");

                ObjectQuery(entityConnection); //This will create the context with existing connection

 

                entityConnection.Close();

            }

            catch (Exception ex)

            {

                Console.WriteLine("\nFAIL! Oops, it was not expected, an exception has been thrown, details below:\n");

                Console.WriteLine(ex.Message);

            }

            Console.WriteLine("\nPress a Key to exit...");

            Console.ReadKey();

        }

        #endregion Main

 

 

        #region ESQL_Query

        /// <summary>

        /// ESQL_Query

        /// (Executing a simple ESQL query against Northwind Entity Set)

        /// Using the entity connection which is passed on as parameter

        /// it executes a simple entity command on the Employees entity set in the Northwind Context.

        /// The result of that query is later on printed on the screen using a data reader.

        /// </summary>

        /// <param name="entityConnection"></param>

        private static void ESQL_Query(EntityConnection entityConnection)

        {

            EntityCommand entityCommand = entityConnection.CreateCommand();

            entityCommand.CommandText = @"Select Emp.Employee_Id as Id, Emp.First_Name as Name from NorthwindEntities.Employees as Emp order by Emp.Employee_Id";

 

            EntityDataReader entityDataReader = entityCommand.ExecuteReader(CommandBehavior.SequentialAccess);

            //Note: You have to use CommandBehavior as SequentialAccess, otherwise an exception will be thrown

 

            while (entityDataReader.Read())

            {

                for (int i = 0; i < entityDataReader.FieldCount; i++)

                    Console.Write(entityDataReader[i].ToString() + "\t");

                Console.WriteLine();

            }

        }

        #endregion ESQL_Query

 

 

        #region LINQ_To_Entity_Query

        /// <summary>

        /// LINQ_To_Entity_Query

        /// (Executing a simple LINQ query against Northwind Entity Set)

        /// This function creates a new Northwind Context based on the setting provided for it in the App.Config File

        /// It executes a simple LINQ query on the Employees entity set in the Northwind Context.

        /// The result of that query is later on printed on the screen using the IQueryable structure.

        /// </summary>

        private static void LINQ_To_Entity_Query()

        {

            NorthwindEntities nwind = new NorthwindEntities(); //Uses the settings for connection string in App.Config File

 

            IQueryable<string> emps = from e in nwind.Employees where (e.Employee_ID%2)==0 select e.First_Name; //Even Number Employee Ids

 

            foreach (string e in emps)

            {

                Console.WriteLine(e);

            }

 

        }

        #endregion LINQ_To_Entity_Query

 

 

        #region ObjectQuery

        /// <summary>

        /// ObjectQuery

        /// (Executing a simple Object query against Northwind Entity Set and Updating the data)

        /// This function creates a new Northwind Context based on the entity connection thas has been passed to it as parameter

        /// It executes a simple Object query on the Employees entity set in the Northwind Context.

        /// The result of that query is later on printed on the screen and some changes are made to it.

        /// The changes are then saved using SaveChanges on Context and then re-querying them to see if things went fine.

        /// </summary>

        /// <param name="entityConnection"></param>

        private static void ObjectQuery(EntityConnection entityConnection)

        {

            NorthwindEntities nwind = new NorthwindEntities(entityConnection);

           

            var emps = nwind.Employees.Where((delegate(Employees e)

                                                {

                                                    return e.Employee_ID > 5;

                                                }

                                            ));

           

            //var emps = nwind.Employees.Where("it.Employee_ID > 5"); //This query is also equivalent to above one and will give same results

            //var emps = nwind.Employees.Where("it.Employee_ID > @empid",new ObjectParameter("@empid",5)); //This query is also equivalent to above one, but it uses parameters for the values

 

            foreach(Employees e in emps)

            {

                Console.WriteLine(e.Employee_ID + "\t" + e.First_Name + "\t" + e.Last_Name + "\t" + e.Country);

                if (e.Employee_ID == 10) //As soon as we encounter employee id as 10, we want to change some data

                {

                    Console.WriteLine("Changing Data");

                    e.First_Name = _newFirstName;

                    e.Last_Name = _newLastName;

                    e.Country = _newCountry;

                }

            }

 

            Console.WriteLine("Saving Data Changes");

            nwind.SaveChanges(); //Any changes made to the context are saved using this command

 

            emps = nwind.Employees; //This is simplest way to select all employees. If you happen to choose particular data you may modify the query accordingly, like nwind.Employees.Where("it.Employee_ID = 10")

 

            Console.WriteLine("Display Data Again:");

            foreach (Employees e in emps)

            {

                Console.WriteLine(e.Employee_ID + "\t" + e.First_Name + "\t" + e.Last_Name + "\t" + e.Country);

            }

 

        }

        #endregion ObjectQuery

 

        }

}

The output of the program would look like this:

SQL CE Northwind Entity App:

 

ESQL Query:

1       Nancy

2       Andrew

3       Janet

4       Margaret

5       Steven

6       Michael

7       Robert

8       Laura

9       Anne

10      Albert

11      Tim

12      Caroline

13      Justin

14      Xavier

15      Laurent

 

LINQ To Entity Query:

Andrew

Margaret

Michael

Laura

Albert

Caroline

Xavier

 

Object Query:

6       Michael Suyama  UK

7       Robert  King    UK

8       Laura   Callahan        USA

9       Anne    Dodsworth       UK

10      Albert  Hellstern       USA

Changing Data

11      Tim     Smith   USA

12      Caroline        Patterson       USA

13      Justin  Brid    France

14      Xavier  Martin  France

15      Laurent Pereira France

Saving Data Changes

Display Data Again:

1       Nancy   Davolio USA

2       Andrew  Fuller  USA

3       Janet   Leverling       USA

4       Margaret        Peacock USA

5       Steven  Buchanan        UK

6       Michael Suyama  UK

7       Robert  King    UK

8       Laura   Callahan        USA

9       Anne    Dodsworth       UK

10      AGENT   SMITH   MATRIX

11      Tim     Smith   USA

12      Caroline        Patterson       USA

13      Justin  Brid    France

14      Xavier  Martin  France

15      Laurent Pereira France

 

Press a Key to exit...

 

If you want your changes to persist or not to persist, modify the properties for the Northwind.sdf file in your solution properties as per your desire. By default it is "copy if newer" which means the database file in your execution folder will retain the changes. By changing it to "copy always" you can refresh your database each time.

I hope now you can now go back and start writing advanced programs using various techniques available.

Ado.Net Entity Framework is a new weapon to the list of a current developer's arsenal, opening multiple ways in which he can write his programs without worrying about the under lying intricacies.

The shift to entity plane seems very lucrative, easy and promising. And what more, all of this comes with handy tools which make life easy. Writing your code from the word Go!

The above topic was in relation to LINQ to Entities, if you are looking for LINQ to SQL refer to this blog post: http://blogs.msdn.com/sqlservercompact/archive/2007/08/21/linq-with-sql-server-compact-a-ka-dlinq-over-sql-ce.aspx

Happy Programming!

 

Ravi Tandon

SDET, SQL Server Compact

Dropping Defaults (Column Constraint)

$
0
0

There were some recent changes that were done in regards to column defaults. In this blog entry I want to bring out, what used to happen and what happens now.

I have discussed the case of dropping a default on a column in this post, however, in a case where you are facing problems dealing with column specific constraints(especially dropping), the appraoch I suggest below should help you with that.

What used to happen in version 3.1 and earlier?


Consider the following query:

CREATE TABLE foo (col INT DEFAULT 1, col2 INT CONSTRAINT cons DEFAULT 2);

Usually when defining defaults one would choose the way it has been done for first column “col”, but even the other options as shown for second column “col2” also works.
In version 3.1 and earlier, if at all you ever decide that you don’t want the default on “col2”, you could issue a statement like this:

ALTER TABLE foo DROP CONSTRAINT cons;

Here, the default for “col2” as declared above will be stored as a constraint with name “cons”, so you could issue an ALTER statement on the table and drop it. It worked.

CREATE TABLE foo (col INT DEFAULT 1, col2 INT CONSTRAINT cons DEFAULT 2)
INSERT INTO foo (col) VALUES (0)
INSERT INTO foo (col2) VALUES (0)
INSERT INTO foo VALUES (0, 0)
INSERT INTO foo VALUES (default, default)
ALTER TABLE foo DROP CONSTRAINT cons
INSERT INTO foo (col) VALUES (0)
 SELECT * FROM foo
                 col                col2
----------------------------------------
                   0                   2
                   1                   0
                   0                   0
                   1                   2
                   0              (NULL)


What changed in version 3.5?


In version 3.5 and onwards the constraint as declared above will not be table constraint anymore, rather the default constraint on a column will be maintained as column property at column level.

So, the statement,

 ALTER TABLE foo DROP CONSTRAINT cons

would NOT work anymore. The “CONSTRAINT cons” from the original statement will be ignored. On issuing above mentioned ALTER statement, you will get an error saying its a bad constraint ID and it cannot be found.

To drop such constraint you will have to issue the following statement (this works on all versions and is the right way to drop the defaults than going  for constraint names):

ALTER TABLE foo ALTER COLUMN col2 DROP DEFAULT

To see the column properties, you can query information_schema.columns. Look for the row with your column name, there will be two columns (COLUMN_HASDEFAULT and  COLUMN_DEFAULT), they indicate whether you have the default on that column or not and the default value for that column, if any.

If you are feeling lazy to type in this, you can also do this through GUI, by editing the table schema in Visual Studio or SQL Server. In the table schema, go to the particular column and for the default property delete the value which you had previously entered. This is equivalent to issuing the above ALTER TABLE statement, in fact, behind the scenes they both use the same statement.


Ravi Tandon
SDET, SQL Server Compact

Query performance

$
0
0

Understanding the reason for slowness of a SQL query and then tuning to boost it is a slightly complicated process, but it can be extremely rewarding in some cases. In this post, I am going to list down some ways in which you can tune the query performance for SQL Server Compact, along with pointers to relevant online resources. If you are a seasoned database developer, you probably know most of the tricks already.

Before I jump into it, an overview of the basics first.

Basics:

  •  Displaying actual and estimated Execution plans for SQL Server Compact: You should be familiar with Execution Plans (also called as query plans and showplans).
    • For non-parameterized queries: There are several easy ways to do this
      • When database is on a docked device or desktop: Generate a query plan using SQL Server Management Studio (SSMS) that gives a nice graphical view of the query plans. (You can connect to the database on device as long as it is docked. No need to copy the file to desktop.)
      • When database is on a device: Generate a query plan using Query Analyzer. This generates a .sqlplan file that can be viewed graphically in SQL Server Management Studio as before (preferable) or opened as a plain XML file.
    • For Parameterized (as well as non-parameterized) queries:
      • Use the TSQL Statements SET SHOWPLAN_XML  (for estimated execution plan) and  SET STATISTICS_XML (for actual execution plan), followed by SELECT @@SHOWPLAN to generate the query plans.  Store the results as an XML file. (Tip: To view the query plans graphically, just rename the file with a .sqlplan extension and it is ready to be opened in SSMS like an ordinary non-parameterized query plan.)
  • Indexes and statistics on indexes:
    • One of the important tasks of the query optimizer is to select the right index to execute the query. An optimizer can make better decisions if it has histogram data (i.e. statistics) about the distribution of values for an index.
      • CREATING/UPDATING/DELETING statistics on an index: SQL Server Compact 3.5 creates statistics on all indexes by default and updates them as required. (You can surely tweak these settings, but it is advisable not to. See CREATE STATISTICS /UPDATE STATISTICS/DROP STATISTICS).
      • To view the statistics distribution, the built in stored procedure sp_show_statistics is pretty handy. 
      • Statistics were not created by default on primary key indexes till version 3.1, so you might want to check this and add them yourself :- ).
  • ... A lot of other things too J, but this will do for the time being.
The Meat:

If you are trying to improve the performance of your application that uses SQL Server Compact, make sure you have checked the following resources on MSDN already (In this post I will not go into any of them):

  • Database Design and Performance: This page talks in some detail about the following:
    • Database denormalization
    • Variable and fixed sized columns
    • Effect of row and key lengths
  • Query Performance Tuning: This page explains some of the following:
    • Improving indexes by creating selective indexes, choosing the columns in a multi-column index, issues in indexing a small table etc.
    • When to create indexes
    • Using parameterized queries where possible.
    • Rewrite queries where possible
    • Using base table cursor (CommandType.TableDirect) mode for simple queries.

(The article on Query Process Overview and Performance Tuning approaches for SQL Server CE 2.0 covers the same points as above, but I found it better than the MSDN links J. It is relevant for SQL Server Compact 3.5 too.)

Now here are some additional ways you can improve performance:

1.       Recompile Stale query plans

<StoryTime>Sometime back I got a complaint about slow performance of our database even though the user was using parameterized queries and had created the correct indexes everywhere. The sequence in which he was performing operations was something like this:

-          Create the full database schema (tables, indexes etc).

-          Prepare SqlCeCommand objects for *all* queries that will ever be used by the application.

-          Populate the database with actual data. Until now all tables were empty.

-          Execute the queries using previously prepared command objects 

What's wrong with this?

 A prepared command object (SqlCeCommand) holds a query plan. The query optimizer generated this query plan and had optimized it for the state of database when the plan was generated. In this user's case, the database had just empty tables at that point in time. The optimizer therefore inferred that using a table scan is the best way of executing the query (as opposed to using any index). As a result, all his query plans used just table scans instead of the right indexes even when the table size increased! 

</StoryTime>

Moral of the story: Caching query plans is good, but only as long as the state of database when they are compiled is representative of the average state of database during execution. If your data is changing rapidly, it is better to recompile the queries every once in a while.

So, beware of stale query plans!

Note that query plans can be cached for both parameterized and non-parameterized queries and you can run into this problem in either case. (Another insider hack: SqlCeCommand.Prepare doesn't really prepare the query plan. It just marks the command object for plan (re)compilation and the plan is compiled when SqlCeCommand.ExecuteXXX is called next time.)

2.       Impression of using parameterized queries without really using them

Question: What's wrong (rather sub-optimal) with the following code:

SqlCeCommand cmd = con.CreateCommand();

cmd.CommandText = "SELECT * FROM table1 WHERE C1_DECIMAL = @p1";

cmd.Parameters.Add("@p1", SqlDbType.Decimal);

cmd.Parameters["@p1"].Value = 3.5;

SqlCeDataReader rdr = cmd.ExecuteReader();

while (rdr.Read()) { /* read the data */}

rdr.Close();


cmd.Parameters["@p1"].Value = 335.01;

rdr = cmd.ExecuteReader();

while (rdr.Read()) {  /* read the data */   }

rdr.Close();


Answer: The query plan gets compiled twice, once for every ExecuteReader call!

Reason: First time the plan is compiled, the parameter's precision is 2 and scale is 1 (as inferred from its value ‘3.5'). The query plan therefore uses this precision and scale values. The only other values it can accept are those that fit within this range.

When the query is executed again, the parameter's precision is 5 and scale is 2 (as inferred from its value ‘335.01'). Since it doesn't fit in the parameter as inferred during first plan compilation, the plan is recompiled silently!

Solution: If you can anticipate the range (size, precision or scale) of the parameter values, then specify it explicitly. The plan will be generated based on the specified range then. This holds true for all character, binary and numeric types. (The flip side is that for any parameter value that does not fit into the specified range, an error will be thrown.) So the above code can be modified as follows:

SqlCeCommand cmd = con.CreateCommand();

cmd.CommandText = "SELECT * FROM [TABLE1] WHERE [C1_DECIMAL] = @p1";

cmd.Parameters.Add("@p1", SqlDbType.Decimal);

cmd.Parameters["@p1"].Precision = 10;  // Playing safe by taking a larger range!

cmd.Parameters["@p1"].Scale = 5;

cmd.Parameters["@p1"].Value = 3.5;

SqlCeDataReader rdr = cmd.ExecuteReader();

while (rdr.Read()) { /* read the data */}

rdr.Close();

cmd.Parameters["@p1"].Value = 335.00;

rdr = cmd.ExecuteReader();

while (rdr.Read()){ /* read the data */ }

rdr.Close();


3.       Query optimizer did not choose the best index

The query optimizer usually does a good job of choosing the index. However, it does it on a best effort basis and there can be cases where it doesn't pick the right index. In such cases, it makes sense to use index hints and outsmart the optimizer:

E.g.  ...FROM [TABLE1] AS T1 JOIN [TABLE2] AS T2...  can be rewritten with index hints as

...FROM [TABLE1] AS T1 WITH (INDEX(IX_On_Table1))

 JOIN [TABLE2] AS T2 WITH (INDEX(IX_On_Table2))...

How do you know if your index is indeed better than the index chosen by optimizer?

Well, the easiest and brute force method is to run the query with and without an index hint and see which is better.  I often use the Query Analyzer on device and SSMS on desktop to get the execution times. Another way is to generate query plans for both queries and study them for better predicate matches, index ordering etc.

4.       Query optimizer did not choose the best join order

As in the case of choosing a wrong index, an optimizer can sometimes choose a wrong join order too. Again a corner case, but not impossible to run into. In such cases, you can specify the join order explicitly:

E.g. ...FROM [TABLE1] AS T1 INNER JOIN [TABLE2] AS T2 ON ...  can be rewritten with a forced join order as 

...FROM [TABLE1] AS T1

 INNER JOIN [TABLE2] AS T2 ON ...

 OPTION (FORCE ORDER)

 As with any sort of query hint, you should be extra careful that you are doing the right thing. For instance, the join order chosen for a query can change between multiple runs due to several reasons. The cardinality of the join tables could have changed significantly, or the data distribution could have changed. So even though the join order that you selected at the time of deployment was optimal, it may not remain so all the time. Ordinarily the optimizer would decide the join order on fly and therefore can adjust to such changes.

Not so when the join order has been forced.

That's all for the time being.

-Pragya Agarwal 

 


Katmai new datatypes support

$
0
0

In Katmai, new datatypes are introduced. Some of these (including some older types in Yukon) are supported for merge replication synching with SQL Compact in SQL Compact 3.5 SP1. These types are mapped to downlevel compatible types for SSC. These types and their mappings are, as follows:

 

SQL type                              Compact type                  Format                               

Date                                     nvarchar(10)                   ‘yyyy-mm-dd’

Time                                     nvarchar(16)                   ‘hh:mi:ss.nnnnnnn”

Datetime2                            nvarchar(27)                   ‘yyyy-mm-dd hh:mi:ss.nnnnnnn’

DatetimeOffset                    nvarchar(34)                  ‘yyyy-mm-dd hh:mi:ss.nnnnnnn [+|-]hh:mi’

Geometry                             image

Geography                           image

 

The format of strings used when inserting/updating the data on SQL Compact, should be same as that given above, or as the type demands, in case of Spatial types.

 

Spatial types are interesting, because, one can map them to image columns on the client without data loss. The data can even be manipulated on the client side, if the required spatial type libraries are present. Other new types in Katmai, like, HierarchyID etc... are not supported for merge with SQL Compact.

 

Thanks

Udaya

Insight into SQL Server Compact database corruptions

$
0
0

Database corruptions are often the most painful bugs to repro and debug. A good percentage of the SQL Server Compact bugs reported are in this category. However it so turns out that in majority of the cases Compact is not the culprit. Surprised!! Let us see why.

How SQL Server Compact detects a file corruption?

Compact database comprises of a series of pages, each 4K in size. When a page is written to disk the following sequence of steps is executed.

 

1.       Compute the checksum on the page data and store it as part of the page.

2.       Encrypt the page.

3.       Write to disk at a given file location or offset.

4.       Update system pages/run time cache with the page offset.

 

When a page is read from disk the following sequence of steps is executed.

 

1.       Read from the disk.

2.       Decrypt the page.

3.       Re-compute the checksum and compare it with the expected value. (If it fails page is not fully baked. Meaning file write failed)

4.       Check if this is the same page that we are expecting as per the system pages/ run time cache. (If this fails we lost a complete page write)

 

If (3) or (4) of the above read steps fail, the db is marked as corrupt and any further db activity is suspended till it is repaired successfully.

 

Notes:

·         Verify reports step (3) errors as “Bad Checksum - idPage: %d, tyPage: %d, iPage: %d”.

·         Verify reports step (4) errors as “Page with valid ordinal not found - idPage: %d, iPage: %d”

What could have triggered the corruption?

1.       A simple device on/off or suspend/resume can result in half-baked file. (No reason to panic as we handle this as described in the next section.)

2.       Compact relies on underlying FAT/TFAT file system to manage the database file. Any bugs in these components can lead to Compact file corruption. Compact stresses file system in many different ways as it tries to keep the file size as small as possible. As it employs shadow paging the writes and reads are quite random. (Note: 6 months back a bug has been identified in FAT/TFAT system that results in a Compact file losing some of the clusters during shrink operation.)

3.       If SD card is being used for db file storage, it’s being equally stressed as the above.

4.       More importantly SD cards bring in additional complexities during Suspend/Resume cycles. Here is a good blog link: http://blogs.msdn.com/windowsmobile/archive/2007/01/12/everything-you-want-to-know-about-sd.aspx

Am I suggesting SQL Server Compact bugs can’t result in any kind of corruption?

Of course Compact code bugs can result in corruption. A lot of them have been found internally before v3.0 release and also reported by customers thereafter. They are more logical in nature like index constraint is compromised or a table page says there are 1000 rows when there are only 55.  We did a very good job in fixing these and they are hard to find now. However Compact bugs don’t result in physical corruptions like “checksum errors” or “page missing” errors.

What does Compact do to prevent corruptions?

We believe most of the corruptions should be due to device suspend/resume or on/off cycles.  For ex: Compact is trying to write to a file and the user simply boots his device. Now file is in half-baked state. Or let’s say process gets killed before it can complete the flush cycle. How do we avoid this?

 

Well, we use shadow paging to overcome this situation. We can loosely categorize the db pages into user data pages, system pages and header page. As the name suggests user data pages contain all the user data. Header pages and system pages help us locate a specific user page on the disk. When it’s time to flush the changes to disk, we write shadows of the user data pages first. Then the shadows of the updated system pages are written. Finally the header page is written. The old pages are retained till the header page is updated. This ensures that we have a transactional write to the disk. Either the change is completely present or not.

Conclusion: Why do we still see corruptions?

Clearly the above is not enough. Some of the interesting cases are

·  What if any of the underlying systems ‘SD card software’ or FAT/TFAT has a bug?

·  Suspend/resume cycle can result in file buffer loss if SD card is used. So the changes supposed to be written to disk could be lost.

         

The intent is not to blame other components. However in the last 3 years, at least 90% of the corruption bugs reported are due to bad checksum. It means disk write is bad for some reason (which is not owned by Compact).  The fault is somewhere in the bottom stack and it has to be fixed. Our options are very limited without a repro but we are trying hard to improve our debugging infrastructure. We are hoping that with this knowledge customers will be able to understand the corruptions better and come up with good practices that would vastly reduce these corruptions. 

Thanks

Raja

Released - SQL Server Compact v3.5 SP1, SQL Server 2008 RTM, Visual Studio 2008 SP1, .NET Framework v3.5 SP1

$
0
0

Yes, all of them are released on August 11, 2008. 

SQL Server Compact v3.5 SP1:

What is new in this Service Pack? - Click here and here

Where to download?

SQL Server Compact v3.5 SP1 for Desktops (32-bit and 64-bit)

SQL Server Compact v3.5 SP1 for Devices (all platforms & processors)

Server Tools (32-bit and 64-bit) (See Also: this)

Documentation, Books Online

Visual Studio 2008 SP1

What is new in this Service Pack? - Click here

Where to download? - Click here

 

.NET Framework v3.5 SP1 - Download it here

SQL Server 2008 RTM - Click here

The good thing is with VS 2008 SP1, you will get "SQL Server Compact SP1 for Desktop (32-bit)", and of course updated "SQL Server Compact SP1 Design Tools".

We received a huge feedback from you on VS 2005 SP1 that we should limit the Service Pack Size.  With that feedback, we felt it is a reasonable to ask customers to download "SQL Server Compact v3. SP1 for Devices" explicitly than including it with Visual Studio 2008 SP1 there by bloating VS 2008 SP1 size.  We also made a decision to not include "SQL Server Compact v3.5 SP1 for Desktops (64-bit)" so as to make sure we do not trouble all VS 2008 SP1 customers.

What about Platform Builder Updates?

Platform Builder 5.0 and 6.0 Updates for SQL Server Compact v3.5 SP1 are also released to Platform Builder team and they should be available in the next Platform Builder 5.0 and 6.0 Update.  I will update this blog post with the download URL soon after they are available. 

Windows CE 5.0 Platform Builder Monthly Update (July 2008) - Download it here

Windows Embedded CE 6.0 Platform Builder Monthly Update (July 2008) - Download it here

 

Thanks,

Laxmi Narsimha Rao Oruganti

Sync Services optimizations

$
0
0


    There are some optimizations that can be done for an "Sync Services" sync scenario. These are, (might not be an exhaustive list)

  1. Small sync chunks (using smaller SyncGroups which are only absolutely necessary)
  2. Index creation on tracking and filtering columns
  3. Transfer encryption of data payload on web
  4. Batching the changes                 
  5. Filtering the data at various stages to reduce network load

    Sync (synonym for "Sync Services sync", in this post) interfaces with the providers using DataSet objects. That is, sync uses DataSet to store and retrieve changes happening at client and server. DataSets are known to be not very memory efficient, and the amount of memory consumed by these, is a bit of a concern when one is using these in device clients in Sync Services. 
 
    Sync happens in chunks, using the SyncGroups that one supplies. That is, all data in a SyncGroup is logically one sync, and corresponds to one DataSet. Since sync DataSets are one per SyncGroup, and these are needed only till the corresponding SyncGroup commits, we can optimize the memory taken by DataSets, using smaller SyncGroups. Divide sync tables into various SyncGroups, so that, each group has it’s own (smaller) DataSet, and it is disposed (by garbage collector) once the SyncGroup changes are committed. However, to ensure logical consistency, you should always keep the tables which are related (by a foreign key constraint, for example), in the same SyncGroup.
 
Example:
Tables Order and OrderDetails are related.
Tables Customers and ShippingDetails are related. But, these are unrelated to the first set.
 
SyncGroup customerSyncGroup = new SyncGroup("Customers");
 
SyncTable customerSyncTable = new SyncTable("Customer");
customerSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
customerSyncTable.SyncDirection = SyncDirection.DownloadOnly;
customerSyncTable.SyncGroup = customerSyncGroup;
 
SyncTable orderShipSyncTable = new SyncTable("ShippingDetails");
orderShipSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
orderShipSyncTable.SyncDirection = SyncDirection.DownloadOnly;
orderShipSyncTable.SyncGroup = customerSyncGroup;
 
SyncGroup orderSyncGroup = new SyncGroup("Orders");
 
SyncTable orderSyncTable = new SyncTable("Order");
orderSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
orderSyncTable.SyncDirection = SyncDirection.DownloadOnly;
orderSyncTable.SyncGroup = orderSyncGroup;
 
SyncTable orderDetailSyncTable = new SyncTable("OrderDetails");
orderDetailSyncTable.CreationOption = TableCreationOption.DropExistingOrCreateNewTable;
orderDetailSyncTable.SyncDirection = SyncDirection.DownloadOnly;
orderDetailSyncTable.SyncGroup = orderSyncGroup;
 
 
    Rather than having a single SyncGroup with all 4 tables, one can create two sync groups. One for the first set, and the second for the other set. 
 
    Also, to increase the performance of enumerating process at server, one can create indexes on the tracking and filtering columns. As an example, let us say one has two tracking timestamp columns __CreateTime and __UpdateTime. Since, our server side changes enumerating queries always have filtering based on these columns, one should create indexes on these, so that, enumerating server changes becomes faster, and, sync performance increases. 
 
    In case of device syncs, transferring the data on the network/internet is also going to cost more time/resources. Since, transfer of data from a web service/server machine to a device is time/bandwidth consuming, one should look at compressing data sent/received. This is mostly the case, when data being synched is large (Something like, initial synching SQL Compact with SQL Server). One can use System.IO.Compression or your own implementation of compression/decompression algorithm. (More details at http://msdn.microsoft.com/en-us/library/system.io.compression.aspx). Another blog post that refers to this issue and proposes solutions is at, (http://blogs.msdn.com/mahjayar/archive/2008/10/01/dbsyncprovider-improving-memory-performance-in-wcf-based-synchronization.aspx)
 
    Sync Services Server side supports batching. Please refer to http://msdn.microsoft.com/en-us/library/bb902828.aspx for more details.  
 
    Sometimes, we may have server tables holding and synching data, that is alien to clients. For example, server table has a large GPS map of some place (in custom format) per row, that is associated with the data in other columns in the row. The map is stored as an image at client side. But, since, the data is of proprietary format, client can’t interpret the data, and it is not used anyway at client side. And also, since, it is large data, lot of network bandwidth is consumed and response time is compromised for transferring this across. It is better, if one can filter these columns out at server side, rather than sending to client. 
 
    Another scenario is as follows: The client devices of a Sync application are used by Salesmen of a company, and the server side is the company office, where data pertaining to each salesman is stored in a SQL Server database. When the client devices sync, they are mostly concerned about the data relevant to them alone, and not to other sales persons. Here also, one needs to filter rows from the table. 
 
    To facilitate filtering of rows/columns at client/server sides, one can use a number of strategies. For filtering data sent from client (or at the client side), one can use the callback architecture of "Sync Services". For server side, since you have more control there, one can choose to strip down the DataSet, when one is sending it over the wire/use callbacks to strip off DataSet data/client can supply queries to server side adapters, which filter data.

Explaining each of these options:

    Callback architecture of sync: Sync provides various callbacks during the process of Synching. One can hook in the callbacks for accessing/modifying the dataset generated at every stage of sync. For example, one can add/drop some columns to the dataset, after changee enumeration is done at client side. After changing the dataset, effectively, the changes being applied to client database are changed. The same provision is present at server side also.

    This callback architecture can be used to modify the DataSet applied/sent to server, on the fly. This is one type of filtering, possible at both client and server.

    Server side gives more options when sending data over the wire. First of all, server chnages are enumerated within the "Sync Services" application itself. That is because, server change enumeration is done by queries supplied by the Sync Services client. So, which columns to select from server, can be controlled from the client side, when specifying queries like, SelectIncrementalInserts etc... This is another way of programmatically filtering server data.

    One more option to filter data in a N-tier architecture is that, filtering the wire transferred content. In an N-tier architecture, client and server are in two different, but connected machines. Typically, client machine has a proxy server provider, which delegates calls to enumeraion/application of changes etc... to a web service. Web service talks to a backend data store, and services the data and operation requests. In this setting, interesting possibilities like, use of compression over the wire, and filtering over the wire etc... come up. When server side data store gives data, it can do some filtering. Also, the client side proxy can be used to filter irrelevant data. This is another type of filtering.

Example for callback architecture:
For client side DataSet filtering (client side), use SelectingChanges before the enumeration and ChangesSelected after the enumeration
For server’s data set filtering (client side), ApplyingChanges before the application of changes and ChangesApplied after the application
For filtering server side changes (at server side):SelectingChanges before the enumeration and ChangesSelected after the enumeration
For client’s data filtering (at server side):ApplyingChanges before the application of changes and ChangesApplied after the application
 
In every one of these methods, eventArgs.GroupMetadata and eventArgs.Context.DataSet are the ones need to be changed.

 Thanks

Udaya Bhanu,

SDE II, SQL Compact

How to: Authoring a 64-bit ClickOnce Bootstrapper package in Visual Studio 2008 SP1

$
0
0

 

Before going into further details first “Disclaimer: This is just to help and does not guaranty that this is approved my employer or me J

 

Location of SQL Compact Bootstrapper

        <BootstrapperDir>\Packages\SQL Server Compact Edition\<LocaleCultureDir>\

Where,

·         <BootstrapperDir>  can be found by reading [HKLM\Software\Microsoft\GenericBootstrapper\3.5]path value otherwise its default value is %ProgramFiles%\Microsoft SDKs\Windows\v6.0A\Bootstrapper\ .

·         <LocaleCultureDir> is culture specific dir, ex: EN, DE, zh-CHS, zh-CHT, …

 

 

Follow the below steps, If you have an ‘Any CPU’ ClickOnce application using SQL Compact 3.5 SP1, for which you want to install SQL Compact x64 MSI on 64-bit machine.

Note: It is required to install both x86 and x64 MSIs on 64-bit OS, since x86 MSI is pre-requirement for x64 MSI.

 

Steps:

1)      Download the SQL Compact 3.5 SP1 x64 MSI and place it under <BootstrapperDir>\Packages\SQL Server Compact Edition\<LocaleCultureDir>\

 

2)      ClickOnce setup.exe is always runs as WoW process on x64 OS, that’s why reading a registry key is not useful for x64 MSI. We can achieve the install check using  <MsiProductCheck> element.

 

Edit the <BootstrapperDir>\Packages\SQL Server Compact Edition\<LocaleCultureDir>\Package.xml file with following details

·         As part  of <InstallChecks> element add <MsiProductCheck> as below

<InstallChecks>

    ---

  <MsiProductCheck Property="SQLCompactRunTimex64Installed" Product="[ProductCode]" />

    ---

</InstallChecks>

 

[ProductCode] is the Product Code/GUID of the x64 MSI. Depending on locale, get it from below table for 3.5 SP1 x64 release.

You can use Orca.exe to get the ProductCode property of a MSI.

 

Locale

Three letter locale Id

Product Code

Chinese

CHS

{8DD60183-76ED-4416-8C9C-E5A39E1826EF}

Chinese (Taiwan)

CHT

{A423B3FB-C9E6-4953-9A83-2A5F45CAF466}

German

DEU

{77CB2F9F-67C5-4ADA-9321-B30C9C64727E}

English

ENU

{F83779DF-E1F5-43A2-A7BE-732F856FADB7}

Spanish

ESN

{5B32AC72-6251-47F4-BD1B-AD479E3EEBA9}

French

FRA

{A64CF374-A3DA-4B1E-A42A-6394C48F431A}

Italian

ITA

{4634B103-984E-4F31-BD80-DCD83AEEEF85}

Japanese

JPN

{1A22CAF6-E6FD-4D65-AEBA-F28D23B68EBF}

Korean

KOR

{38514244-6C25-42EC-B144-276F6DDAC9CE}

Portuguese (Brazil)

PTB

{C8445DBB-783F-4804-B373-D5CDC0614E60}

Russian

RUS

{CAA59A81-E35A-4582-80FF-F19520FFF60F}

 

3)      Add <PackageFile> element for x64 MSI. Replace [ThreeLetterLocaleID] with three letter locale id mentioned in above table.

 

<PackageFiles>

    ---

<PackageFile Name="SSCERuntime-[ThreeLetterLocaleID]-x64.msi"    PublicKey="3082010a0282010100a2db0a8dcfc2c1499bcdaa3a34ad23596bdb6cbe2122b794c8eaaebfc6d526c232118bbcda5d2cfb36561e152bae8f0ddd14a36e284c7f163f41ac8d40b146880dd98194ad9706d05744765ceaf1fc0ee27f74a333cb74e5efe361a17e03b745ffd53e12d5b0ca5e0dd07bf2b7130dfc606a2885758cb7adbc85e817b490bef516b6625ded11df3aee215b8baf8073c345e3958977609be7ad77c1378d33142f13db62c9ae1aa94f9867add420393071e08d6746e2c61cf40d5074412fe805246a216b49b092c4b239c742a56d5c184aab8fd78e833e780a47d8a4b28423c3e2f27b66b14a74bd26414b9c6114604e30c882f3d00b707cee554d77d2085576810203010001" />

</PackageFiles>

 

4)      Add <Command> elements for x64 MSI.

 

     </Commands>

            <!--  Install case for the x64 redist   -->

       <Command PackageFile="SSCERuntime-[ThreeLetterLocaleID]-x64.msi" Arguments="">

<InstallConditions>

            <!--  ByPass if we have installed the x64 redist   -->

  <BypassIf Property="SQLCompactRunTimex64Installed" Compare="ValueGreaterThan" Value="0" />

            <!--  Install only on AMD64 Processor   -->

  <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="AMD64" />

            <FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired" />

  </InstallConditions>

   <ExitCodes>

  <ExitCode Value="0" Result="Success" />

  <ExitCode Value="1641" Result="SuccessReboot" />

  <ExitCode Value="3010" Result="SuccessReboot" />

  <ExitCode Value="4123" Result="SuccessReboot" />

  <DefaultExitCode Result="Fail" String="Anunexpected" FormatMessageFromSystem="true" />

</ExitCodes>

       </Command>

 

            <!--  Reinstall/Repair case for the x64 redist   -->

       <Command PackageFile="SSCERuntime-[ThreeLetterLocaleID]-x64.msi" Arguments="REINSTALL=ALL">

<InstallConditions>

            <!--  Check if we haven’t  installed the x64 redist, no need to repair it   -->

  <InstallIf Property="SQLCompactRunTimex64Installed" Compare="ValueGreaterThan" Value="0" />

            <!--  Install only on AMD64 Processor   -->

  <BypassIf Property="ProcessorArchitecture" Compare="ValueNotEqualTo" Value="AMD64" />

            <!--  This is the actual condition for reinstalling the x64 MSI  -->

  <BypassIf Property="ENU_INST_GAC" Compare="ValueExists" />

  <FailIf Property="AdminUser" Compare="ValueEqualTo" Value="false" String="AdminRequired" />

</InstallConditions>

<ExitCodes>

  <ExitCode Value="0" Result="Success" />

  <ExitCode Value="1641" Result="SuccessReboot" />

  <ExitCode Value="3010" Result="SuccessReboot" />

  <ExitCode Value="4123" Result="SuccessReboot" />

  <DefaultExitCode Result="Fail" String="Anunexpected" FormatMessageFromSystem="true" />

</ExitCodes>

       </Command>

      </Commands>

5      

          5) For making AnyCPU SQL Compact 3.5 SP1 Clickonce app to download 64-bit and 32-bit MSIs from microsoft download site (In this case, you can skip step 1), you need to do following additial things.

              a) Add HomeSite attribute to the 64-bit <PackageFile> element. 

<PackageFiles>

    ---

<PackageFile Name="SSCERuntime-[ThreeLetterLocaleID]-x64.msi" 

  HomeSite="HomeSiteName_64"   

  PublicKey="3082010a0282010100a2db0a8dcfc2c1499bcdaa3a34ad23596bdb6cbe2122b794c8eaaebfc6d526c232118bbcda5d2cfb36561e152bae8f0ddd14a36e284c7f163f41ac8d40b146880dd98194ad9706d05744765ceaf1fc0ee27f74a333cb74e5efe361a17e03b745ffd53e12d5b0ca5e0dd07bf2b7130dfc606a2885758cb7adbc85e817b490bef516b6625ded11df3aee215b8baf8073c345e3958977609be7ad77c1378d33142f13db62c9ae1aa94f9867add420393071e08d6746e2c61cf40d5074412fe805246a216b49b092c4b239c742a56d5c184aab8fd78e833e780a47d8a4b28423c3e2f27b66b14a74bd26414b9c6114604e30c882f3d00b707cee554d77d2085576810203010001" />

</PackageFiles>

b) Add <String> for HomeSiteName_64 in <Strings>

 <Strings>

       ---

      <String Name="HomeSiteName_64">[x64MSIDownloadURL]</String>

       ---

 </Strings>

 

           In place of [x64MSIDownloadURL] put download URL for locale specific x64 Runtime MSI.

           Below is the list of locale specific download URLs for x64 3.5 SP1 Runtime MSIs. 

English: http://download.microsoft.com/download/8/4/2/8423C019-CCB4-4D7D-B7F0-BCF83F1B9218/SSCERuntime-ENU-x64.msi

German: http://download.microsoft.com/download/1/5/1/1517BA39-EAC3-4281-900B-AFB77369169A/SSCERuntime-DEU-x64.msi

Spanish: http://download.microsoft.com/download/C/B/E/CBE7CA6E-0D13-4186-A3CD-03C74CE9A0FA/SSCERuntime-ESN-x64.msi

French: http://download.microsoft.com/download/3/A/3/3A3B694E-9742-4AFF-8357-DCC9BAAE8A40/SSCERuntime-FRA-x64.msi

Italian: http://download.microsoft.com/download/9/E/F/9EF6D714-80EA-4373-962C-60436ED8A1D8/SSCERuntime-ITA-x64.msi

Japanese: http://download.microsoft.com/download/D/7/1/D717C79C-D847-42BF-BB9C-C1C390D203C4/SSCERuntime-JPN-x64.msi

Korean: http://download.microsoft.com/download/B/5/7/B5773FB4-1593-4746-824D-15235D820EFC/SSCERuntime-KOR-x64.msi

Portuguese (Brazil): http://download.microsoft.com/download/D/3/8/D388E5C0-8671-4F6A-8A05-86B9470B4E97/SSCERuntime-PTB-x64.msi

Russian: http://download.microsoft.com/download/2/3/E/23EB9CB1-F037-463F-BE83-AD3848FD1480/SSCERuntime-RUS-x64.msi

Chinese: http://download.microsoft.com/download/9/A/0/9A04CFE5-29CB-4B5C-A5F9-C66CB5FD1A9B/SSCERuntime-CHS-x64.msi

Chinese (Taiwan): http://download.microsoft.com/download/D/E/B/DEB711BD-FE6A-45E9-AA15-D9901E8458C3/SSCERuntime-CHT-x64.msi

 

 

 

ClickOnce Reference: http://msdn.microsoft.com/en-us/library/ms229223(VS.80).aspx

 

 

Thanks

Manikyam Bavandla

 

Overview of SqlCeReplication methods - LoadProperties and SaveProperties

$
0
0

Whenever sync is started, developers provide all the necessary properties to an object of SqlCeReplication class. These properties are provided through the constructors or by directly setting the public properties of the object. In this approach developers need to provide this data for every sync, which forces them to store this data somewhere in their code. Even if the properties seldom change, developers provide this data all the time. This data includes passwords such as DistributorPassword, InternetPassword, InternetProxyPassword and PublisherPassword which developers are better off, not saving or handling in their code.

This blog article throws light on SaveProperties/LoadProperties methods which provide a good solution to issues described above. SaveProperties saves all the properties a developer can provide to SqlCeReplication object (except for two which are described below) in a system table called __sysMergeSubscriptionProperties within the replicated database. The benefits of this approach are:

1)      The replicated database can be encrypted securing this data inside the sdf file.

2)      Passwords are encrypted with the unique device hardware key enabling an extra layer of security.

3)      Data that seldom changes need not be explicitly provided by developer for every sync

Code example for calling SaveProperties:

// Example code for SaveProperties starts

repl = new SqlCeReplication();

repl.InternetUrl = "http://www.adventure-works.com/sqlmobile/sqlcesa35.dll";

repl.InternetLogin = "MyInternetLogin";

repl.InternetPassword = "<enterStrongPassword>";

repl.Publisher = "MyPublisher";

repl.PublisherDatabase = "MyPublisherDatabase";

repl.PublisherLogin = "MyPublisherLogin";

repl.PublisherPassword = "<enterStrongPassword>";

repl.Publication = "MyPublication";

repl.Subscriber = "MySubscriber";

repl.SubscriberConnectionString = "Data Source=MyDatabase.sdf";

 

repl.SaveProperties();

 

// Example code for SaveProperties ends

Note: SaveProperties will succeed only if the Subscription is already created on the machine.

 

This simplifies subsequent syncs in that developers need to provide only SubscriberConnectionString (to identify the local database) to SqlCeReplication object and call LoadProperties. If __sysMergeSubscriptionProperties table has only one record this data is automatically loaded into SqlCeReplication object. If there are more records, then in additional to SubscriberConnectionString, developers need to provide Publication, Publisher and PublisherDatabase to uniquely identify a saved profile for a subscription.

Code example for calling LoadProperties:

// Example code for LoadProperties starts

repl = new SqlCeReplication();

repl.SubscriberConnectionString = "Data Source='Test.sdf'; Pwd='<enterStrongPassword>'";

 

repl.LoadProperties(); // assuming only one subscription’s properties are saved

 

// Example code for LoadProperties ends

LoadProperties/SaveProperties thus provide an efficient way to store and retrieve data relieving developers from maintaining sensitive and unchanging data.

Properties not saved by SaveProperties:

SendTimeout and ReceiveTimeout properties are not saved via SaveProperties. These values must be explicitly provided to SqlCeReplication object for every sync.

Note:

There are two things to note while using this functionality.

1)      Before calling SaveProperties, please make sure all necessary properties are set on the SqlCeReplication object. If we call SaveProperties with required properties missing, this data will be set to default even if there is a saved profile already present for this subscription in the Properties table.

2)      Passwords stored are encrypted with the unique device hardware key. Therefore if the database file is moved to a different machine LoadProperties will fail to retrieve the correct password. Developers need to provide the password and other required properties, and call SaveProperties again to refresh the saved profile on the new machine.

For more information please refer MSDN documentation:

a)      SqlCeReplication.SaveProperties - http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlcereplication.saveproperties.aspx

b)      b) SqlCeReplication.LoadProperties - http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlcereplication.loadproperties.aspx

Thanks,
Balasubramaniam Bodedhala

 

After moving the database from one platform to other, the first SqlCeConnection.Open() takes more time

$
0
0

 

 

If you move a SQLCE database from one platform to other, it's first SqlCeConnection.Open() takes more time and also increases the database file size.

 

The Reason: For an index on string type columns, SQLCE uses LCMapString API to get the normalized sort key. LCMapString API behavior will be different for different NLS sort versions. NLS sort version is different for Desktop Windows OS and WM/WCE. During the first database connection open, SQLCE rebuilds all indexes if there is a NLS sort version mismatch with the last accessed OS platform. Index recreation requires space on database file and hence the database file size will be increased. You can use Compact()/Shrink() API to get the database file with approximately old file size.  Because of this index recreation, first database connection open takes more time as it has to rebuild all indexes.  

Note: If your database doesn’t have any indexes you will not see above mentioned symptoms on first connection open.

 

 

Don’t inter-op SQLCE 3.0 databases between devices and desktop:

SQLCE started supporting desktops only from SQLCE 3.1 (3.0.5300.0) release. SQLCE 3.0 doesn’t have index rebuilding logic and the index re-creation was added during SQLCE 3.1 (3.0.5300.0) release as it is required to support platform inter-op for SQLCE databases.  On desktop you can open SQLCE 3.0 databases, which were created on devices. Again If you open these databases on SQLCE 3.0 devices, your device app might receive an error/exception.

 

For example: Opening a SQLCE 3.0 database with SSMS will use SQLCE 3.1 bits on desktop and hence it would drop and recreate index data. When this file is copied back to device, index data may not be valid and receive an error/exception.

 

Namaskaram!

Manikyam Bavandla

 

SQL Server Compact Garbage Collection – Whys and Hows

$
0
0

Some background about SQL Server Compact:

SQL Server Compact is an embedded database implemented in native and it can be accessed in application by either OLEDB or ADO.NET provider model.

ADO.NET provider for SQL Server Compact is a managed assembly which depends on native SQL Server Compact DLLs to provide the service. In general, the managed classes under ADO.NET provider model for SQL Server Compact are just wrappers around the native classes.

SQL Server Compact native objects are dependent. For instance, Cursors and Transactions are dependent on Connection object and are expected to be released in the right order.

What’s the problem then? In native application, the developer can dispose the cursors, commands, etc. before closing the connection but in managed application with .Net Garbage Collector there is no particular order in which these objects will be disposed.

So what do we do? Our SqlCeConnection object maintains weak references to all objects tied with it. Or to be specific, it maintains short weak references.

How does it help me in disposing the objects in order? When the connection object is getting disposed, the weak reference cache is iterated and all the objects there are disposed before the connection object getting disposed. Please note that when we say Dispose, we also mean Finalization.

How does .Net Garbage Collector comes into picture of SQL Server Compact

Simply employing short weak references to keep track of all related objects and dispose them in sequence does not solve all the problems.

What is the problem then? Sometimes the database files can remain locked in stress scenarios because not all the dependent objects are disposed upon dispose of SqlCeConnection. This happens because we use short weak refs to track object lifetime and we could end up in situations in which an object is in the finalization queue (hence the short reference is not longer alive) and isn’t in the freachable queue (hence isn’t guaranteed to be picked up by the GC immediately). More information about short weak references can be found here.

All this leads to a situation, where the database file is still locked even though customer application closed the connection.  Hence, it is not able to get deleted the file using file explorer …etc means.

How did we solve the problem? When we are cleaning weak reference cache in dispose of  SqlCeConnection object, we need to call GC.WaitForPendingFinalizers()  before we return to the caller; in this way, we are guranteed that the  GC will pick up all finalizable objects and hence all the native  interfaces will be properly released even if we no longer have short  references to them.

More information about this API can be found here.

FAQs

1. Why are we employing short weak references and not long weak references?

Ans.: SQL Server Compact ships for both Desktops as well as Devices. Long weak references are not supported in .Net CF. More information here.

2. Does call to GC.WaitForPendingFinalizers() has negative performance impact?

Ans.: No. Most of the time, the freachable queue  is empty (the same is not true for finalization queue though). See here for more information about Garbage Collector.

3. Can this call to GC.WaitForPendingFinalizers() lead to deadlocks?

Ans.: Yes. If Dispose method of SQL CE objects are called in the finalization context than the explicit dispose context. The reason being when an object is getting finalized, it is not supposed to touch any other managed objects as the currently getting disposed object does not know the life-status of the object it is trying to refer.

4. Why did we choose this design?

Ans.: SQL CE was primarily designed for Devices where the memory, processing comes at very high cost.  So, it has been designed to free up the resources as early as we can and hence it is calling GC.WaitForPendingFinalizers.

Thanks,

Mohammad Imran.

Troubleshooting: Access Violation exception while using SQL Server Compact database with ADO.NET provider

$
0
0

 

Possible causes for Access Violation exception in general:

 

An access violation occurs in unmanaged or unsafe code when the code attempts to read or write to memory that has not been allocated, or to which it does not have access. This usually occurs because a pointer has a bad value.

In programs consisting entirely of verifiable managed code, all references are either valid or null, and access violations are impossible. An AccessViolationException occurs only when verifiable managed code interacts with unmanaged code or with unsafe managed code.

 

For more information about this, please visit this link.

 

When this exception can be related to SQL Server Compact:

 

SQL Server Compact ADO.NET provider DLL [System.Data.SqlServerCe.dll] is a managed DLL which interacts with other native DLLs to provide the functionality.

 

There are two known issues related to the usage of SQL Server Compact provider which may lead to this Access Violation exception:

 

1.      Version Mismatch [3.5 RTM and 3.5 SP1]:

 

Access Violation occurs when the loader loads different versions of Managed and Native SQL Server Compact 3.5 DLLs. This issue arises when different versions are available in the box and this happens with Private and Central deployment of SQL Server Compact 3.5.

 

To be specific, if SQL Server Compact 3.5 RTM is pre-installed [centrally deployed] in the box and application built on top of SQL Server Compact 3.5 SP1 privately deploys the SQL Server Compact DLLs.

 

In this case, the managed DLL [System.Data.SqlServerCe.dll v3.5.5692.0] will be loaded from private directory but the native DLLs [sqlceme35.dll, sqlceqp35.dll, etc. v3.5.5386.0] might get loaded from the central deployed directory.

 

If the application is built against SQL Server Compact 3.5 RTM and SQL Server Compact 3.5 SP1 is centrally deployed in the box then the application will start using SQL Compact 3.5 SP1 as there is a redirection entry which redirects an application (Compiled against 3.5 RTM) to use centrally deployed SQL Compact 3.5 SP1.

   

2.      Thread Safety:

 

SQL CE objects are not thread-safe and are not thread affinitive either. If an instance of SqlCeConnection or SqlCeTransaction is shared across threads without ensuring thread safety, then that may lead to Access Violation exception.

 

 

Work-around if the cause is related to SQL Server Compact:

 

For the above two issues, there are workarounds available which should be followed to avoid any Access Violation exception.

 

1.      Version Mismatch:

 

One should follow either of the given below approaches to avoid the Access Violation exception:

 

Scenario: Application built against SQL Server Compact 3.5 SP1 [to be deployed privately] and SQL Server Compact 3.5 RTM centrally deployed.

 

Solution:

1.  There should be only one version of SQL Server Compact [v3.5 RTM or v3.5 SP1] installed in the box. The version with which the application is not built against [v3.5 RTM] should be un-installed.

2.  Install SQL Server Compact [v3.5 SP1] centrally to avoid any future install mismatch.

 

Forum thread related to this issue can be found here.

 

2.      Thread Safety:

 

It is recommended that each thread should use a separate connection than sharing across. If there is really a need for sharing SQL CE objects across threads, then the application should serialize access to these objects.

 

Thanks,

Mohammad Imran.


SQL CE Binaries - Details

$
0
0

 

Many times developers get puzzled on which exact set of binaries one should consume in their application.  There is also a misconception that SQL CE engine is too big in size.  This may be because there was no effort from our side to clarify on “Which binary is for what purpose?”. 

In an effort to get clarity in these aspects, I have published a blog post on my blog.  Please do read and provide your comments.

 

Thanks,

Laxmi Narsimha Rao Oruganti

 

Merge replication vs. Sync Services for Compact

$
0
0

 

SQL Server Compact supports predominantly two different sync technologies. “Merge replication” and “Sync Services”. Users might be using one or the other, and interested in knowing the differences between the two technologies, from a use-case point of view. Still, there might be others interested in knowing, which technology better suites their need, by comparing and choosing the right one. One simple rule of thumb here: Merge replication is designed keeping enterprises in mind, where Sync Services is a framework for developer community/social networking/hobbyist programmers etc… (everything else). “Merge replication” is a solution, which is suitable for Enterprises mostly, in preference to Sync services. However, Sync services is an open-ended, extensible framework on top of which, one can do almost everything that Merge replication does. This article concentrates mostly on the merge replication angle in terms of where it makese more sense and where it doesn't.

 

Where does "Merge" make more sense? 

In the enterprise scenario. In my opinion, enterprises like things faster, better (without any issues), and easily do-able/repeatable. If a solution (like “Merge replication”) allows them to do things like “setting up a publication, subscribers etc…”, although with significant coding, people are not going to like it. So, tools and wizards for enterprises are mandatory (Also give them a way to re-do the setups, typically outputting scripts from these tools/wizards). To avoid the setup/upgrade glitches, provide an out-of-the-box integration story, with other often used components (like Windows, IIS, SQL Server, HTTP etc…). Also, tighter integration helps performance. Usually, in enterprise contexts, setting up a “data server and clients” is a long-term commitment, so, tighter integration is fine there. All these are basic requirements for the “Enterprise” oriented “merge replication” technology.

 

Note: There are many ways in which a tighter integration with other components helps deployments.

1.       Efficiency/performance

2.       Automation possibility and tooling

3.       Better end-2-end support/solution story for the customers

4.       Ability to monitor and troubleshoot parts of the system

5.       Essentially, you leave all the hardwork to us, and in the end, expect something that automatically works J (Means, reduced cost of development and testing for you)

 

                Also, my take is that “Enterprises like rich (and relevant) features”. Give them something that can easily model/extend their business logic, and that could be of great value to them. Some of the features of “Merge replication”, in this category are,

 

1.       Automatic partition management

2.       Custom conflict resolution hooks

3.       Business logic plugins to do custom processing, in the process of merge replication

a.       Example is, if one wants to charge the client for synching

b.      One wants to compute his share whenever a salesman syncs to the server

4.       Retention cleanup, which can be used to (weakly) set a stringent policy about incremental syncs.

a.       Like, every salesman must sync at least once in a week or every branch office, must sync at least once a day.

5.       Incremental schema changes replication

6.       Integration with SQL Server mirroring

7.       Integration with SQL Server backup and restore.

 

Other valuable features are, “Automatic identity range management” etc. I hope now it is very clear as to, why “merge replication” technology is good for enterprise businesses. Enterprises do not mind, buying into a special architecture, if that provides value. Enterprises can setup a particular set (at the least) of windows machines, with IIS and SQL Server, and run merge replication. So, a tailored solution, like merge replication is best suited for them.

 

Where does Sync play better role compared to Merge? 

Now, let’s examine another use-case. Incidentally, in this use-case, the features of merge replication, do not seem much relevant. You want to write a stock-alert application, and link it with a stock-tick source on a website. On closer examination, this is also a “data sync” scenario, so, merge replication could be used here. Trying to use merge replication here, elicits many incompatibilities/redundancies, that are not relevant to this use-case.

 

First of all, the nature of the data source is unknown, it can change while the app is running too. The web-site might use SQL backend now, and something else tomorrow. The transport is not known, it is over HTTP, but, can have any format (plain HTML/Json etc…). There is no need of rich data semantics here, as one is just comparing a single piece time-series data, and deciding to throw the alert or not. Also, one does not need a big database at client, all he does is read and discard (or read, alert and discard). Clearly, using merge replication here is an overkill, and unsuitable. So, you should use “Sync services”.

 

                If you want to write a very quick sync app, and use it anywhere*, “Sync services” is the answer. Because Sync Services, is not tied to any particular, server architecture or transport mechanism, one can use it anywhere*. For quick development of sync apps, Sync Services is integrated with Visual Studio. But, this is only to develop the app quickly, not to deploy it. Visual Studio is not even needed for plain development of any sync app. It is just there to make it easy and fast.

 

                Sync services is amazingly extensible, componentized, customizable. While merge replication answers enterprise use-case, which is a typical use-case for data synchronization, virtually all other use-cases are addressable by “Sync services”. If for some reason, people do not want to use a particular server/transport architecture, (or can’t use a single architecture), Sync services is the way to go. Besides, Sync services is a free platform to develop apps on. It is a great tool to enable non-(traditional)-enterprise related, businesses/users to realize the new models of interaction cropping up almost everywhere now. Sync services can be made to have feature-parity with “merge replication” solution through coding, although, I hope you would agree that it is not the intent of Sync services. I quoted that here, only to make you realize the potential of Sync services platform.

 

When an open-ended sync solution needs to be developed, Sync Services Framework is the one to use. Many times in usage, applications to sync data, need heterogeneous servers/transports etc. This is a very important capability, for example, for news generation and propagation web-site. News could be present in various web-sites, and also inside documents/databases of different formats. Also, the solution should be open-ended and extensible, so that, it can be easily tailored for a new data source. The importance of “Sync services” in enabling such scenarios, should not be underestimated. Sync Services, is coming out strong, and there is more to watch out in this field, going forward. With this, we conclude the explanations of the technologies, from the use-cases point of view.

 

The list of features of merge replication and Sync services are tabulated below:

 

Feature

Supported in merge replication

Supported in Sync Services

Enterprise-centric

 

 

Type of the technology

Solution

Framework

Target users

Enterprises with DBAs

Developers/Hobbyists/Social networking Communities

Integration with DBA tools (SQL Server)

Yes

No

More tooling support

Yes

No

Pluggable business logic hooks

Yes

No

Conflict resolution support

Built-in + support for custom***

Built-in + extensible**

Schema propagation support

Initial + any changes

Limited, available by extension**

Partitioning support

Built-in

Available by extension

Server type (State-full or State-less)

State-full

State-less

Integration with Server mirroring (SQL Server)

Yes

No

Integration with Server backup/restore (SQL Server)

Yes

No

Identity ranges management

Yes

No

 

 

 

Developer centric

 

 

Type of the technology

Solution

Framework

Target users

Enterprises with DBAs

Developers/Hobbyists/Social networking Communities

Developer platform support

No

Yes, Visual Studio integration provided

Pluggable transport

No (HTTP with IIS server only)

Yes (Web service model is possible, by extension)

Heterogeneous server

No (Only SQL Server)

Any server is good (by extension).

Network architectures

Fixed, 3-tier

Variable, 2-tier to N-tier

Supports web services model

No

Yes

Ability to work with other sync platforms/frameworks

No

Yes (by extension)

Exposed API surface for tracking****

No

Yes

 

 

 

 

 

Common functionality provided

 

 

Subscribed database deployment

Yes

Yes

Type of change tracking used

ROWGUID

PK or ROWGUID

Sync directions allowed

All

All

Programmability layer

Native & managed

Managed

 

 

 

Semantics provided

 

 

Auto-management of dependent tables

Yes

No

Sync granularity enforced

Yes (Publication level)

No (table level)

Schema propagation

Yes

Limited extent

Built-in conflict resolution strategies (also customizable)

Yes

Only some limited number of built-ins

 

 

* Well, almost everywhere.

** Whenever we use, “available by extension” or simply “by extension”, that means developer should write code to achieve the desired behavior.

*** (For this document,) the difference between customizable and extensible is the following: customization is a type of extension, where, the application architecture is not affected majorly. Like, register a COM dll, to do conflict resolution etc…

**** Tracking is a mechanism used to tag all changes. Changes could be Inserts/Updates/Deletes on tracked tables. This module is used to detect changes between successive syncs, so that the data can be forwarded to the other party. Exposing the tracking API (enable/disable tracking etc…), helps write applications like peer-peer sync, transaction notifications etc…

 

Wrap-up:

We have looked at the use-cases where merge replication technology is suitable and where it is not. There are scenarios where “Sync services” comes out as a candidate for solution, and there are scenarios for merge replication too. When considering the right technology for using, there is no silver bullet; there is no panacea that works for all needs. The requirements of your use determine the “right” technology for you. Merge replication provides a solution, but, there are many scenarios that it can’t help you with. Sync services can be made to work in “any” scenario (including the one that merge replication provides out-of-the-box
J), but, are you fine with building such a (mammoth) architecture yourself, and incurring the various costs involved? In merge replication, we take the pains and give you a solution, although, for a special, tailored need, is also happens to be the most common and justified one. In sync services, you are on your own, but, it gives many benefits that you can’t do without in many situations.

 

Contributor: Udaya Bhanu Goteti

Microsoft SQL Server Compact 3.5 with Service Pack 2 released with Visual Studio 2010 and on the Web.

$
0
0

The latest release of SQL Server Compact also referred to as SQL CE or SQL Server Mobile, released with Visual Studio 2010 on the 12th of April 2010. SQL Server Compact 3.5 SP2 is a SQL Server Compact 3.5 with SP2 release, meaning that installing it on a machine using the Windows Installer (MSI) file upgrades the existing installation of SQL Server Compact 3.5 or SQL Server Compact 3.5 SP1 on the machine to SP2.

The main features for SQL Server Compact 3.5 SP2 are as given below:

  • Supports working with a SQL Server Compact 3.5 database using the Transact-SQL Editor in Visual Studio 2010. The Transact-SQL Editor can be used to run free-text Transact-SQL queries against a SQL Server Compact 3.5 database. The Transact-SQL Editor also provides the ability to view and save detailed estimated and actual query show-plans for SQL Server Compact 3.5 databases. Previously, the functionality provided by the Transact-SQL Editor was only available through SQL Server Management Studio.
  • New classes and members named SqlCeChangeTracking have been added to the System.Data.SqlServerCe namespace to expose the internal change tracking feature used by Sync Framework to track changes in the database. The SQL Server Compact change tracking infrastructure maintains information about inserts, deletes, and updates performed on a table that has been enabled for change tracking. This information is stored both in columns added to the tracked table and in system tables maintained by the tracking infrastructure. By using System.Data.SqlServerCe.SqlCeChangeTracking one can configure, enable, and disable change tracking on a table, and also access the tracking data maintained for a table. The API can be used to provide functionality in a number of scenarios. For example it can be used to provide custom implementations of client-to-server or client-to-client sync for occasionally connected systems (OCS) or to implement a custom listener application.
  • The managed assemblies of SQL Server Compact for use by the applications that privately deploy SQL Server Compact are installed in the folder %Program Files%\Microsoft SQL Server Compact Edition\v3.5\Private. Using these assemblies ensure that the application uses the privately deployed version of Compact even when a lower version of SQL Server Compact 3.5 is installed in the GAC.
  • Visual Studio 2010 installs both the 32-bit and 64-bit versions of SQL Server Compact 3.5 SP2 on a 64-bit machine. If a SQL Server Compact application is deployed using Click Once in Visual Studio 2010 then both the 32-bit and the 64-bit version of SQL Server Compact are installed on a 64-bit machine
  • SQL Server Compact 3.5 SP2 supports Windows 7 and Windows Server 2008 R2, and can sync data using merge replication with SQL Server 2008 R2 November CTP.
  • A list of the bug fixes in SQL Server Compact 3.5 SP2 will be also released as a KB article similar to the KB article - http://support.microsoft.com/default.aspx?scid=KB;%5bLN%5d;955965 within two weeks. Apart from the bug fixes, the hot fixes that were released for SQL Server 2005 Compact Edition or SQL Server Compact 3.5 SP1 have been rolled up in SQL Server Compact 3.5 SP2. The list of hot fixes is as given below:
    • http://support.microsoft.com/kb/953259: Error message when you run an SQL statement that uses the Charindex function in a database that uses the Czech locale in SQL Server 2005 Compact Edition: "The function is not recognized by SQL Server Compact Edition"
    • http://support.microsoft.com/kb/958478: Error message when you run a "LINQ to Entities" query that uses a string parameter or a binary parameter against a SQL Server Compact 3.5 database: "The ntext and image data types cannot be used in WHERE, HAVING, GROUP BY, ON, or IN clauses"
    • http://support.microsoft.com/kb/959697: Error message when you try to open a database file from a CD in SQL Server Compact 3.5 with Service Pack 1: "Internal Error using read only database file"
    • http://support.microsoft.com/kb/960142: An error message is logged, and the synchronization may take a long time to finish when you use an application to synchronize a merge replication that contains a SQL Server 2005 Compact Edition subscriber
    • http://support.microsoft.com/kb/963060: An error message is logged, and the synchronization may take a long time to finish when you synchronize a merge replication that contains a SQL Server Compact 3.5 subscriber: "UpdateStatistics Start app=<UserAppName>.exe"
    • http://support.microsoft.com/kb/967963: Some rows are deleted when you repair a database by using the Repair method together with the RepairOption.RecoverCorruptedRows option in SQL Server 2005 Compact Edition and in SQL Server Compact 3.5
    • http://support.microsoft.com/kb/968171: Error message when you try to create an encrypted database in SQL Server 2005 Compact Edition: "The operating system does not support encryption"
    • http://support.microsoft.com/kb/968864: Error message when you run a query in SQL Server Compact 3.5: "The column name cannot be resolved to a table. Specify the table to which the column belongs"
    • http://support.microsoft.com/kb/969858: Non-convergence occurs when you synchronize a SQL Server Compact 3.5 client database with the server by using Sync Services for ADO.NET in a Hub-And-Spoke configuration
    • http://support.microsoft.com/kb/970269: Access violations occur when you run an application under heavy load conditions after you install the 64-bit version SQL Server Compact 3.5 Service Pack 1
    • http://support.microsoft.com/kb/970414: Initial synchronization of a replication to SQL Server Compact 3.5 subscribers takes significant time to finish
    • http://support.microsoft.com/kb/970915: Error message when you synchronize a merge replication with SQL Server 2005 Compact Edition subscribers: "A column ID occurred more than once in the specification. HRESULT 0x80040E3E (0)"
    • http://support.microsoft.com/kb/971027: Error message when you upgrade a very large database to SQL Server Compact 3.5: "The database file is larger than the configured maximum database size. This setting takes effect on the first concurrent database connection only"
    • http://support.microsoft.com/kb/971273: You do not receive error messages when you run a query in a managed application that returns columns of invalid values in SQL Server Compact 3.5
    • http://support.microsoft.com/kb/971970: You cannot insert rows or upload changes into the SQL Server 2005 Compact Edition subscriber tables after you run the "sp_changemergearticle" stored procedure or you add a new merge publication article when another article has an IDENTITY column
    • http://support.microsoft.com/kb/972002: Error message when you try to create an encrypted database in SQL Server Compact 3.5: "The operating system does not support encryption"
    • http://support.microsoft.com/kb/972390: The application enters into an infinite loop when you run an application that uses Microsoft Synchronization Services for ADO.NET to synchronize a SQL Server Compact 3.5 database
    • http://support.microsoft.com/kb/972776: When the application calls the SqlCeConnection.Close method or the SqlCeConnection.Dispose method in SQL Server Compact 3.5, the application may stop responding at the method call
    • http://support.microsoft.com/kb/974068: Error message when an application inserts a value into a foreign key column in SQL Server Compact 3.5: "No key matching the described characteristics could be found within the current range"

Downloads for SQL Server Compact 3.5 SP2:

The Web downloads for SQL Server Compact 3.5 SP2 is as listed below:

SQL Server Compact 3.5 SP2 for Windows desktop (32-bit and 64-bit)

Note that the file available for download is a 6 MB self-extracting executable (exe) file that contains the 32-bit and the 64-bit Windows Installer (MSI) files for installing SQL Server Compact 3.5 SP2 on a 32-bit and a 64-bit Computer. It is important to install both the 32-bit and the 64-bit version of the SQL Server Compact 3.5 SP2 MSI on a 64-bit Computer. Existing SQL Server Compact 3.5 applications may fail if only the 32-bit version of the MSI file is installed on the 64-bit computer. Developers should chain both the 32-bit and the 64-bit MSI files with their applications and install both of them on the 64-bit Computer. Refer to the KB article for more information.

SQL Server Compact 3.5 SP2 for Windows mobile devices (all platforms & processors)

SQL Server Compact 3.5 SP2 Server Tools (32-bit and 64-bit)

SQL Server Compact 3.5 SP2 Books Online (The Books Online is available for download)

SQL Server Compact 3.5 SP2 Samples

Visual Studio 2010 and .NET Framework 4

 

Regards,

Ambrish Mishra

Program Manager

 

 

Troubleshooting: Privately deploying the SQL Server Compact 3.5 SP2 ADO.NET Entity Framework provider (System.Data.SqlServerCe.Entity.dll) in the application folder does not work

$
0
0

For complete instructions about deploying SQL Server Compact ADO.NET Entity Framework provider (System.Data.SqlServerCe.Entity.dll) privately in the application’s folder refer to the blog here. Note that from SQL Server Compact 3.5 SP2 release onwards if you are privately deploying SQL Server Compact 3.5 SP2 DLLs in your application folder you need to copy the managed DLLs (System.Data.SqlServerCe.dll and System.Data.SqlServerCe.Entity.dll) from the location %Program Files%\Microsoft SQL Server Compact Edition\v3.5\Private. Refer to the SQL Server Compact 3.5 SP2 Books Online for more information.

Symptoms

When an application uses System.Data.SqlServerCe.Entity.dll from SQL Server Compact 3.5SP2 in xcopy (i.e. private) deployment mode by copying the Compact’s ADO.NET provider (System.Data.SqlServerCe.dll) and the Compact’s ADO.NET EF provider (System.Data.SqlServerCe.Entity.dll) DLLs from the %Program Files%\Microsoft SQL Server Compact Edition\v3.5\Private, following exception is thrown:
"System.IO.FileLoadException: Could not load file or assembly 'System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)"

Cause

System.Data.SqlServerCe.Entity.dll and System.Data.SqlServerCe.dll from the Private folder is of version 3.5.1.50. But unfortunately, the System.Data.SqlServerCe.Entity.dll from the Private folder (i.e. with version 3.5.1.50) is referring to System.Data.SqlServerCe.dll from the Desktop folder (i.e. with version 3.5.1.0). Due to this, an application that has only the dlls from Private folder fails as it doesn't find the 3.5.1.0 version of System.Data.SqlServerCe.dll.

Resolution

Add assembly binding redirection entry in app.config file.
Append following lines under the configuration section of the app.config:

   <runtime>
    <
assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <
dependentAssembly>
        <
assemblyIdentity name="System.Data.SqlServerCe" publicKeyToken="89845dcd8080cc91" culture="neutral"/>
        <
bindingRedirect oldVersion="3.5.1.0-3.5.1.50" newVersion="3.5.1.50"/>
      </
dependentAssembly>
    </
assemblyBinding>
  </
runtime>

- Vipul Hattiwale

Introducing SQL Server Compact 4.0, the Next Gen Embedded Database from Microsoft

$
0
0

Microsoft SQL Server Compact 4.0 is the next generation of embedded database from the SQL Server family, and brings all of its goodness to the world of ASP.NET web application development. SQL Server Compact 4.0 will provide an easy and simple to use database storage for starter websites, and the features of Compact that wooed the mobile devices and desktop developers will now be available to the ASP.NET web application developers. In addition, the features and enhancements in SQL Server Compact 4.0 like the new Transact-SQL syntax for OFFSET & FETCH, higher reliability, seamless migration of schema and data to the higher SKUs of SQL Server, support for code-first & server generated keys in ADO.NET Entity Framework 4.0, and the ability to use Visual Studio 2010 to develop ASP.NET web applications for Compact 4.0 etc. will also excite the existing development community.

 

The first Community Technology Preview (CTP1) release of SQL Server Compact 4.0 is integrated with the WebMatrix Beta, which is a free ASP.NET web application development tool for Windows, and provides development & database support, and can easily publish/deploy websites to the web hosting providers. SQL Server Compact 4.0 CTP1 plays an important role in WebMatrix Beta, and enables WebMatrix Beta to be a small download, with a simple development experience, and contributes to the seamless end-to-end experiences from development through to publish. Scott Guthrie’s (ScottGu) blog has detailed information about the WebMatrix Beta and its different components. WebMatrix Beta can be installed in one-click through the Microsoft Web Platform Installer (Web PI) 3 Beta. In addition to the Web PI 3 Beta, SQL Server Compact 4.0 CTP1 is also available for download from the Microsoft download center.

 

The topics that are covered in the blog are listed below. SQL Server Compact will be referred to by its abbreviated form wiz. Compact throughout this blog for easy reading:

1.      Specialty of SQL Server Compact – Highlights the reasons for using SQL Server Compact for application development. The section will be useful for the ASP.NET developers and will be a reaffirmation for the existing Compact developers.

2.      New Features in SQL Server Compact 4.0 CTP1 – The section lists the new features in the first CTP release of Compact 4.0 and will be of interest to both the ASP.NET and the existing Compact development community.

3.      Known Issues in SQL Server Compact 4.0 CTP1 – The known issues in the first CTP release of Compact 4.0 and the workarounds are listed in this section.

1.    Specialty of SQL Server Compact:

SQL Server Compact has many specialties that are well liked by the developer community. The specialties of Compact, among others, are as listed below:

·        Small Size: Easy to download with a small size of 2 to 2.5 MB and installs fast with no configuration needed.

·        Program with .NET Framework APIs: Simple to use because of the familiar .NET Framework APIs, including ADO.NET and ADO.NET Entity Framework, and similar programming patterns.

·        Supports Transact-SQL Syntax: Supports a rich subset of the Transact-SQL syntax supported by higher SKUs of SQL Server.

·        Private (xcopy) Deployable: Xcopy deployable within the application folders and no admin privileges are needed. The database file contains no code and is safe to deploy along with the database. 

·        In-process Database: Loads in the application’s process memory space and requires no inter-process communication.

·        Integrated with Visual Studio: Applications can be rapidly developed using the integrated development experience in Visual Studio.

·        Easy Migration to SQL Server: Smooth on-ramp to SQL Server when the applications requirements grow and there is a need to handle large amounts of data and high concurrent loads due to multiple users.

·        Free Product with Free Tools: Compact is a free product, and is integrated with the free Express versions of Visual Studio and WebMatrix Beta, and requires low investment to start building and deploying applications.

·        Simple Solutions for Syncing data with SQL Server: Schema and data can be synced easily with SQL Server using inbuilt and programmable technologies like Sync Framework (Sync FX) and merge replication.

2.    New Features in SQL Server Compact 4.0 CTP1

The first CTP release of SQL Server Compact 4.0 has a lot of features that will be useful to all of the development community of Compact, including the latest entrants, the ASP.NET developers. The different features of SQL Server Compact 4.0 CTP1 categorized separately are as described below:

2.1  Fundamentals

The set of features in this category are improvements that made Compact better, more reliable and secure. More details about the features are given below:

  1. Higher Reliability – SQL Server Compact 4.0 CTP1 has been tested and certified to work with ASP.NET web applications and can handle the load of starter websites. Compact 4.0 CTP1 performs without any exceptions or access violations in scenarios where there are a number of concurrent connections and multiple requests are being made to the database.
  2. Encryption Algorithm Update – Compact 4.0 CTP1 supports the SHA 2 encryption algorithms that provide a higher level of security for the encrypted Compact database files and are also needed for the FIPS compliance. The algorithms that were supported in the earlier versions of Compact are only supported in Compact 4.0 CTP1 for opening the database file to upgrade them to Compact 4.0 CTP1. Due to this, when Compact 4.0 CTP1 opens a Compact 3.5 database file, the Compact 3.5 database file will need to be upgraded to Compact 4.0 CTP1 using the System.Data.SqlServerCe.SqlCeEngine.Upgrade() API.
  3. Setup Enhancements – SQL Server Compact 4.0 CTP1 setup and installation has been enhanced to ensure that the x86 and x64 components of SQL Server Compact install properly on a 64-bit machine. This is done to ensure that Compact 4.0 CTP1 supports both the WOW64 mode and the 64-bit native applications on the 64-bit machine without any problems, in both the conditions i.e. when Compact is deployed centrally using the exe installer or when it is privately deployed within the application folders.  
    1. In Compact 4.0 CTP1, the x86 exe will install on a 32-bit machine and the x64 MSI will install on a 64-bit machine only. The x64 MSI will install both the 32-bit and 64-bit Compact components on the 64-bit machine and due to this the x86 MSI is no longer needed to be installed on the 64-bit machine.
    2. If one wants to do a private deployment of Compact 4.0 CTP1, all the assemblies (both 32-bit and 64-bit) for the private deployment will be available in the %Program Files%\Microsoft SQL Server Compact Edition\v4.0\Private and in the %Program Files (x86)%\Microsoft SQL Server Compact Edition\v4.0\Private folder.

2.2  Improvements for ASP.NET Web Applications

  1. Support for ASP.NET – Compact 4.0 CTP1 supports ASP.NET without the need for any specific configuration. The flag SQLServerCompactEditionUnderWebHosting is not required in Compact 4.0 CTP1 and has been removed.
  2. Virtual Memory Reduction – The virtual memory that Compact uses has been reduced in Compact 4.0 CTP1. The visible difference is that if an application tries to open 40 to 50 simultaneous connections in SQL Server Compact 3.5 SP2, an ‘out of virtual memory’ exception will be hit. With Compact 4.0 CTP1, the application can easily open as many connections as needed to the database file up to the full extent of 256 connections without running out of virtual memory.
  3. Medium Trust – Compact 4.0 CTP1 assemblies have been attributed with Allow Partially Trusted Caller’s Attribute (APTCA) and Compact 4.0 CTP1 can run in medium trust.

2.3  Develop Compact 4.0 CTP1 Applications with WebMatrix Beta and Visual Studio 2010

  1. Seamless Migration of Data and Schema from Compact 4.0 CTP1 into SQL Server – The WebMatrix Beta can be used to script data and schema from Compact 4.0 CTP1 into the higher versions of SQL Server. The WebMatrix Beta can be also used to script data and schema from Compact 4.0 CTP1 to SQL Azure. The script to SQL Azure is in an early (alpha) stage for this first CTP release.
  2. Designer Support in WebMatrix Beta – The WebMatrix Beta can be used to develop ASP.NET web applications with Compact 4.0 CTP1 and to manage the Compact database including running T-SQL queries against Compact.
  3.  Designer Support in Visual Studio 2010 – An update to Visual Studio 2010 is also being worked upon that will provide support for using Compact 4.0 in Visual Studio 2010. Compact 4.0 will be also supported in Visual Studio 2010 Web Developer Express.

2.4  New Transact-SQL Syntax

  1. Support for Paging Queries – Compact 4.0 CTP1 supports the T-SQL syntax for OFFSET & FETCH, and due to this paging queries can be run against the database file. A few sample T-SQL queries for OFFSET & FETCH that can be run against the sample Northwind.sdf database file are given below:

·        The query below skips the first 10 rows and fetches all the other rows in the Employees table ordered by the Hire Date:

SELECT * FROM Employees ORDER BY [Hire Date] OFFSET 10 ROWS;

·        The first query below skips the first 10 rows and fetches the next 10 rows in the Customers table and the rows are ordered by the Customer ID. The second query skips the first 2 rows and fetches the next one row in the Orders table ordered by the Shipped Date. This query a variation of the first query:

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

SELECT * FROM Orders ORDER BY [Shipped Date] OFFSET 2 ROWS FETCH NEXT 1 ROW ONLY;

2.5  API Enhancement

  1. Seamless Integration with ADO.NET Entity Framework 4.0 (.NET FX 4) – Compact 4.0 CTP1 will support the code-first programming model of ADO.NET Entity Framework. In addition, the columns that have server generated keys like identity, rowguid etc. will be also supported in Compact 4.0 when used with ADO.NET Entity Framework 4.0 (this is the version of ADO.NET Entity Framework that released with .NET FX 4). The ADO.NET Entity Framework is working on a separate release and that will provide the code-first and server generated keys support for Compact.
    1. The Compact 4.0 CTP1 release only works with ADO.NET Entity Framework 4.0 that released with .NET FX 4. Using Compact 4.0 CTP1 with ADO.NET Entity Framework 3.5 SP1 that released with .NET Framework 3.5 SP1 will result in an error.
  1. New API for GetSchema: Compact has a new API - System.Data.SqlServerCe.SqlCeConnection.GetSchema() – that can be used to get the schema from a Compact database file. The API is also used to provide the support for System.Data.Common.DbConnection.GetSchema. In the example below the GetSchema API is used to get the names of all the tables, columns, indexes, indexed columns and foreign keys from the sample Northwind.sdf database.

SqlCeConnection conn = new SqlCeConnection("DataSource=Northwind.sdf");

       try

            {

                conn.Open();

 

                DataTable dt = conn.GetSchema();

                dt = conn.GetSchema("Tables");

                dt = conn.GetSchema("Columns");

                dt = conn.GetSchema("Indexes");

                dt = conn.GetSchema("IndexColumns");

                dt = conn.GetSchema("ForeignKeys");

 

            }

            catch (Exception e)

            {

                //Fail

            }

  1. New API for SqlCeConnectionStringBuilder: Compact is has new API - System.Data.SqlServerCe.SqlCeConnectionStringBuilder() – that let developers programmatically create correct connection string for Compact 4.0, and to parse & rebuild existing connection strings. The API is also used to provide the support for System.Data.Common.DbConnectionStringBuilder. In the example below the SqlCeConnectionStringBuilder performs checks for valid key/value pairs and creates a valid SQL Server Compact connection string.

       System.Data.SqlServerCe.SqlCeConnectionStringBuilder builder =

            new System.Data.SqlServerCe.SqlCeConnectionStringBuilder();

       builder["Data Source"] = "Northwind.sdf";

       builder["Mode”] = "Exclusive";

       Console.WriteLine(builder.ConnectionString);

 

The result is the following connection string:

Data Source=Northwind.sdf;Mode=Exclusive

3.    Known Issues in SQL Server Compact 4.0 CTP1:

The known issues in this CTP release of Compact 4.0 are listed below:

1.      Compact 4.0 CTP1 needs Visual C++ 2008 Runtime Libraries (x86, IA64 and x64), Service Pack 1: The native DLLs of SQL Server Compact 4.0 CTP1 need the Microsoft Visual C++ 2008 Runtime Libraries (x86, IA64 and x64), Service Pack 1. Installing the SQL Server Compact 4.0 CTP1 using the Windows Installer (.exe) file, also installs the Visual C++ 2008 Runtime Libraries SP1. If SQL Server Compact 4.0 CTP1 is deployed privately in the application’s folder the following have to be present on the machine for SQL Server Compact to function properly:

a.      Installing the .NET Framework 3.5 SP1 also installs the Visual C++ 2008 Runtime Libraries SP1.

b.      Visual C++ 2008 Runtime Libraries SP1 can be downloaded and installed from the location given below: http://go.microsoft.com/fwlink/?LinkId=194827

Note that installing .NET Framework 2.0 or 3.0 or 4 does not install the Visual C++ 2008 Runtime Libraries SP1.

2.      Uninstallation and repair of Compact 4.0 CTP1 from the command line does not work: Uninstallation of Compact runtime using command line options does not work in this CTP release. For uninstallation of SQL Server Compact runtime go to Add/remove programs (Start->Run->appwiz.cpl), and right click on the entry ‘Microsoft SQL Server Compact 4.0 ENU CTP1’ or ‘Microsoft SQL Server Compact 4.0 x64 ENU CTP1’ , and select uninstall from the menu.

3.      Compact 4.0 development support in Visual Studio 2010: An update to the Visual Studio 2010 is being worked upon that will add the support for Compact 4.0. The update will also provide for the development support for Compact 4.0 in the Visual Studio 2010 Web Developer Express.

4.      Code first programming model support for Compact 4.0 in ADO.NET Entity Framework: The Microsoft ADO.NET Entity Framework Feature Community Technology Preview 3 is an early preview of the code-first programming model for the ADO.NET Entity Framework 4.0. The code-first feature in the ADO.NET Entity Framework CTP3 release does not work properly with Compact 4.0. Future releases of code-first programming model for ADO.NET Entity Framework will provide support for code-first programming model for Compact 4.0.

 

Regards

Ambrish Mishra

Program Manager – SQL Server Compact

 


Downloads Available for SQL Server Compact 4.0 CTP2, Visual Studio 2010 SP1 Beta Tools for SQL Server Compact 4.0 CTP2, and CMS (mojoPortal, Orchard and Umbraco) that work with SQL Server Compact.

$
0
0

The second community technology preview release of SQL Server Compact 4.0 is available for download from the Microsoft Download Center or as part of the Microsoft WebMatrix Beta 3 in the Microsoft Platform Installer 3.0. To learn more about Microsoft WebMatrix Beta 3 see the WebMatrix Beta Book and video tutorials.

An update to the Microsoft Visual Studio 2010 SP1 Beta has been also released that provides for support for SQL Server Compact 4.0 CTP2 in Visual Studio 2010 SP1 Beta. Follow the steps below to enable support for SQL Server Compact 4.0 CTP2 in Visual Studio 2010 SP1 Beta. For more information refer to the Visual Studio 2010 SP1 Beta help page:

1.      Download and install Microsoft Visual Studio 2010 SP1 Beta.

2.      To use SQL Server Compact with the Visual Studio 2010 SP1 Beta, install the following packages from the Microsoft Web Platform Installer 3.0:

a.      Microsoft SQL Server Compact 4.0 CTP2

b.      Microsoft Visual Studio 2010 SP1 Tools for SQL Server Compact 4.0 CTP2

The following open source content management systems support SQL Server Compact as the database and can be used to rapidly build websites:

1.      mojoPortal and more information is at mojoPortal’s site.

2.      Orchard and more information is at Orchard’s site.

3.      Umbraco and more information is at Umbraco’s site.

 

Thanks,

Ambrish Mishra

Program Manager

Microsoft SQL Server Compact 4.0 is available for download

$
0
0

The SQL Server Compact team is happy to announce that the next version of Microsoft SQL Server Compact 4.0 has been released, and is available for download with the Microsoft Web Platform Installer 3 or from the Microsoft Download Center.

SQL Server Compact 4.0 has been designed, developed, tested and tuned over the course of last year and the release has been also vigorously verified by the vibrant MVP and developer community. The feedback from the developer community has helped improve the quality of the SQL Server Compact 4.0 release and the Compact team would like to thank all community members who participated in the release.

The main value proposition of SQL Server Compact 4.0 is the ability to use it as a data store for ASP.NET web applications. Please take a moment to go through the scenarios in which SQL Server Compact 4.0 will not work. For these scenarios SQL Server Compact 3.5 SP2 is the right choice.

Reasons for using SQL Server Compact 4.0:

  1. Database for ASP.NET Web Applications and Web Sites: Compact 4.0 has been optimized and tuned for use for ASP.NET web applications and has been field tested to ensure that Compact 4.0 can handle the load of starter websites and scale up to a database size of 4 GB.
    1. Default database for Microsoft WebMatrix: Compact 4.0 is the default database for Microsoft WebMatrix, which is the web stack that encapsulates all the technologies like ASP.NET, IIS Express, Editor and SQL Server Compact that are needed to develop, test and deploy ASP.NET websites to third party website hosting providers.
    2. Rapid website development with free, open source web applications: Popular open source web applications like mojoPortal, Orchard, Umbraco etc. support Compact 4.0 and can be used to rapidly develop, test and deploy websites.
    3. Partial trust and virtual memory: Compact 4.0 works in partial trust that is the mainline scenario in which the ASP.NET web applications are deployed. The virtual memory used by Compact 4.0 has been optimized to ensure that that maximum allowed 256 connections can be opened for the database.   
    4. One click migration to SQL Server: As the requirements grow to the level of enterprise databases, the schema and data can be migrated from Compact to SQL Server using the migrate option in the WebMatrix IDE. This also adds a web.config xml file to the project that contains the connection string for the SQL Server. Once the migration completes, the website project seamlessly switches from using Compact to SQL Server.
    5. Removes the soft block for use in ASP.NET web applications: In the earlier versions of Compact a flag, namely, SQLServerCompactEditionUnderWebHosting had to be flipped to use Compact in ASP.NET web applications. The flag has been removed in Compact 4.0.   
  2. Enhancements of the fundamentals (setup, deployment, reliability, and encryption algorithms): The bases of Compact 4.0 have been strengthened to ensure that it can be installed without any problems, and can be deployed easily, and works reliably while providing the highest level of security for data. 
    1. Consistent setup and install experience and small download: There are separate MSIs for x86 and x64 platforms, and the x64 MSI installs the Compact components in both the WOW mode and the native mode in - %Program Files (x86)%\Microsoft SQL Server Compact Edition\v4.0, and in %Program Files%\Microsoft SQL Server Compact Edition\v4.0. The x86 MSI has been blocked from installing Compact components on an x64 platform, and similarly x64 MSI has been blocked from installing on x86 platform. This leads to a consistent installation and setup experience and also avoids future issues in Service Pack releases, where a higher version of SP1 x86 MSI can overwrite the GACed assemblies with a higher version on an x64 platform. The issue was faced in the Compact 3.5 SP2 release and the knowledge base article no 974247 describes the issue in more detail. All these setup improvements have been done while keeping the small download size of Compact intact at 2.5 MB.
    2. Easy private deployment: All the x86 and x64 Compact assemblies and DLLs that need to be privately deployed are in the folder - %Program Files%\Microsoft SQL Server Compact Edition\v4.0\Private. The contents of the folder can be copied in the application directory to privately deploy Compact. Both the x86 and x64 MSIs install the x86 and x64 Compact assemblies and DLLs in the Private folder and there is no need to install the x64 MSI on an x86 platform to get the x64 DLLs. Note that the native DLLs of SQL Server Compact need the Microsoft Visual C++ 2008 Runtime Libraries (x86 and x64) SP1 to function properly. The assemblies for the Visual C++ 2008 runtime are present in the Private folder, and deploying all the DLLs and folders in the Private folder deploys all the files needed for Compact to work properly.
    3. Higher reliability: The ASP.NET web applications have a different workload than the desktop applications. Compact has been tested for handling the workload of starter websites, and this has made the product more reliable than the earlier versions. 
    4. Highly secure: Compact 4.0 uses SHA2 algorithm to secure data and provide a high level of security. Compact 4.0 is also FIPS compliant and can be used in applications that need FIPS compliance.
  3. ADO.NET Entity Framework, API and T-SQL syntax enhancements: Compact 4.0 also has enhancements for Entity Framework, APIs and T-SQL syntax as described below:
    1. ADO.NET Entity Framework 4 (.NET FX 4) code-first and server generated keys: Compact 4.0 works with the code-first programming model of ADO.NET Entity Framework. In addition, the columns that have server generated keys like identity, rowguid etc. are also supported in Compact 4.0 when used with ADO.NET Entity Framework 4.0 (this is the version of ADO.NET Entity Framework that released with .NET FX 4). Support for the code-first and for the server-generated keys rounds out the Compact support for ADO.NET Entity Framework and fulfills one of the main asks from the development community.
    2. T-SQL syntax for OFFSET & FETCH: Compact 4.0 supports the T-SQL syntax for OFFSET & FETCH, and due to this paging queries can be run against the database file.
    3. API enhancements: Compact adds in the support for two new APIs. The first one is the System.Data.SqlServerCe.SqlCeConnection.GetSchema() that can be used to get the schema from a Compact database file. The API is also used to provide the support for System.Data.Common.DbConnection.GetSchema. The second new API is the  System.Data.SqlServerCe.SqlCeConnectionStringBuilder() that let developers programmatically create correct connection string for Compact 4.0, and to parse & rebuild existing connection strings. The API is also used to provide the support for System.Data.Common.DbConnectionStringBuilder.
  4. Easy application development in Visual Studio 2010: Visual Studio 2010 provides for rich designers and easy debugging that can be used to develop ASP.NET web applications for Compact 4.0. See the Visual Studio 2010 SP1 Beta help page for information on installing the required components to develop applications for SQL Server Compact 4.0.

Scenarios not enabled by SQL Server Compact 4.0:

The SQL Server Compact was focusing on enabling the new scenarios for ASP.NET Web Applications, and due to time and resource constraints the following scenarios have not been enabled in SQL Server Compact 4.0. For these scenarios the SQL Server Compact 3.5 SP2 is the right choice.

  1. Data replication with SQL Server: Compact 4.0 does not support data replication with SQL Server using Sync Framework, merge replication or remote data access (RDA). 
  2. LINQ to SQL: The LINQ to SQL does not work with Compact 4.0.
    1. The ADO.NET Entity Framework 4 that ships in .NET FX 4 works with Compact 4.0, and additional features like support for code-first and server generated keys have been added in Compact 4.0 for EF 4.
  3. Windows Mobile, Windows Phone and Windows CE devices: Compact 4.0 does not have a release for Windows Mobile, Windows Phone or for Windows CE devices.
  4. Designers in the VB or C# Windows projects in Visual Studio 2010 SP1 Beta: The following wizards do not work with Compact 4.0 in the Windows project system. Developers can manually add reference to the ADO.NET provider for Compact 4.0 (System.Data.SqlServerCe) to develop programs for Compact 4.0 in the Windows projects:
    1. The Data Source Configuration Wizard that is used to configure datasets.
    2. The Configure Data Configuration wizard that is used to setup the syncing of data and schema with SQL Server using Sync FX.
    3. The Entity Data Model wizard that is used to generate entities from a Compact database.

Known Issues:

The SQL Server Compact 4.0 Books Online and the updated read me will be available on the Microsoft Download Center by the third week of Jan, 2011. The Books Online and the read me will provide the required information for developing applications with SQL Server Compact 4.0 and the list of known issues and supported platforms. For more information about Microsoft WebMatrix refer to the links below:

Thanks,

Ambrish Mishra

Program Manager - SQL Server Compact

SQL Server Compact 4.0 Tooling Support in Visual Studio 2010 SP1 and Visual Web Developer Express 2010 SP1

$
0
0

Quick Navigation Links:

 

Overview

 

Advantages of using Visual Studio 2010 SP1 or Visual Web Developer Express 2010 SP1 to develop applications for SQL Server Compact 4.0

 

Visual Studio Designers that do not work with SQL Server Compact 4.0

 

Fixing installation issues

 

 

Overview

 

The Ultimate, Premium and Professional editions of Visual Studio 2010 SP1, and the Visual Web Developer Express 2010 SP1 has support for tooling for SQL Server Compact 4.0. The Visual Studio 2010 SP1 and the Visual Web Developer Express 2010 SP1 can be installed using the Microsoft Web Platform Installer 3.0. After installing the Web Platform Installer 3.0, the screen as shown below will come up. Click on the Add button to install the Visual Studio 2010 SP1 and the Visual Web Developer Express 2010 SP1.

 

 

Screenshot 1: Web Platform Installer 3.0 with the option to install Visual Studio 2010 SP1 or Visual Web Developer Express 2010 SP1. 

 

Note that selecting and installing the Visual Studio 2010 SP1 or the Visual Web Developer Express 2010 SP1 also installs the SQL Server Compact 4.0 components that are needed for the tooling support. These components are called as Visual Studio 2010 SP1 Tools for SQL Server Compact 4.0 and SQL Server Compact 4.0. The Web Platform Installer automatically detects whether these components are already installed on the machine, and if they are not installed, the Web Platform Installer will install them. There is no need to separately select the SQL Server Compact 4.0 components in the Web Platform Installer.

Back to the top

  

Advantages of using Visual Studio 2010 SP1 or Visual Web Developer Express 2010 SP1 to develop applications for SQL Server Compact 4.0

 

The Visual Studio 2010 SP1 can be used to develop ASP.NET web applications for Compact 4.0. The different designers that provide functionality for Compact 4.0 is as given below:

 

Server Explorer and Query Designer: After installing the Compact 4.0 components for Visual Studio 2010 SP1, a new option to connect to SQL Server Compact 4.0 databases will appear in the Change Data Source dialog. This option will be in-addition to the existing option to connect to the SQL Server Compact 3.5 databases. After connecting to a SQL Server Compact 4.0 databases, the different objects in it can be navigated through in the Server Explorer and queries can be run in the Query Designer window.

 

 

Screenshot 2: Change Data Source dialog for selecting SQL Server Compact 4.0 data source. 

 

Transact-SQL Editor: Start the Transact-SQL Editor from the Data menu and connect to a SQL Server Compact 4.0 database in the Connect to Server dialog shown below by specifying the path to the database file or by selecting the New Database option in the Database file dropdown field. Note that when the path to the database file is specified, the version of file is auto-detected, and depending on the version of the file either SQL Server Compact 3.5 or SQL Server Compact 4.0 runtime engine is used to connect to the file. This behavior is different from that in the Add Connection and Change Data Source dialogs of the Server Explorer where the data source has to be explicitly set to Compact 3.5 or 4.0. The Create New SQL Server Compact Database dialog provides options for creating either Compact 3.5 or Compact 4.0 database file as shown in the screenshot below.

 

 

Screenshot 3: Connecting to a SQL Server Compact 4.0 database in the Transact-SQL Editor connection window. 

 

 

Screenshot 4: Creating a new SQL Server Compact 4.0 database. 

 

Designers in the VB and C# ASP.NET Web application or web site projects: Designers can be used in the VB and C# based ASP.NET Web Application or Web Site projects to generate datasets or entities from a Compact database and these can be bound to controls on the ASP.NET web page. The workflow is same as that used for SQL Server and more information about the controls are at the SqlDataSource and the EntityDataSource web control pages. In the Add New Item dialog box a new item template for SQL Server Compact 4.0 Local Database is available to add a new empty Compact 4.0 database file to the project.

 

Click once deployment: In the prerequisites dialog of the click once deployment there is a checkbox for Compact 4.0 and if the VB or C# Windows projects uses Compact 4.0 the click once publishing for Compact 4.0 will work if the Compact 4.0 entry is checked in the prerequisites window. 

 

 

Screenshot 5: The prerequisites dialog for Click Once deployment. 

 

Opening WebMatrix projects in Visual Studio 2010 SP1: A WebMatrix project can be opened in Visual Studio 2010 SP1 or in Visual Web Developer Express 2010 SP1 by clicking on the Visual Studio option in the WebMatrix IDE. In addition, if the required SQL Server Compact 4.0 components that are needed for Visual Studio 2010 SP1 are not installed on the machine, a message will pop-up to start the Web Platform Installer 3.0 and the Web Platform Installer 3.0 will install all the required components on the machine.

Back to the top  

Visual Studio Designers that do not work with SQL Server Compact 4.0

 

The following wizards do not work with Compact 4.0 in the Windows project system. Developers can manually add reference to the ADO.NET provider for Compact 4.0 (System.Data.SqlServerCe) to develop programs for Compact 4.0 in the Windows projects:

 

- The Data Source Configuration Wizard that is used to configure datasets.

- The Configure Data Configuration wizard that is used to setup the syncing of data and schema with SQL Server using Sync FX

- The Entity Data Model wizard that is used to generate entities from a Compact database.

Back to the top  

Fixing installation issues

 

If you face any issues in installing the SQL Server Compact 4.0 components do the following:

 

Go to Start à Control Panel à Programs à Programs and Features to see the list of all the applications and software installed on your machine. Another way to navigate is to open the Windows Explorer and copy in – Control Panel\Programs\Programs and Features – in the address bar at the top. Check to see whether the following are installed. On a 32-bit machine the name will show as Microsoft SQL Server Compact 4.0 x86 ENU:

 

 

Screenshot 6: Entries for SQL Server Compact in the Add/Remove Programs. 

 

If the Microsoft Visual Studio 2010 SP1 Tools for SQL Server Compact 4.0 is not installed type in SP1 in the search bar at the top right in the Web Platform Installer. This will bring up all the components that have SP1 in their name. Click on the Add button in front of Microsoft Visual Studio 2010 SP1 Tools for SQL Server Compact 4.0 to install it. The Microsoft Visual Studio 2010 SP1 Tools for SQL Server Compact 4.0 can be only installed if there is an existing installation of Visual Studio 2010 SP1 or Visual Web Developer Express 2010 SP1. Similarly if you have trouble installing SQL Server Compact 4.0, type in SQL Server Compact 4.0 in the search bar and click on the Add button to install it. The information about the different executable files for installing different SQL Server Compact 4.0 components is at MSDN Online.

 

 

Screenshot 7: Searching for all products with SP1 in their name. 

 

 

Screenshot 8: Highlighting Microsoft Visual Studio 2010 SP1 Tools for SQL Server Compact 4.0. 

 

 

Screenshot 9: Searching for SQL Server Compact 4.0 and highlighting SQL Server Compact 4.0. 

Back to the top  

Regards,

 

Ambrish Mishra

 

Program Manager – SQL Server Compact

 



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>