Tuesday, 7 June 2016

How to add a reference to SQL Server Compact 4.0 for Central Deployment


  1. In Solution Explorer, right-click References and select Add Reference.
    Note
    If the References folder is not listed in Solution Explorer, click Show All Files at the top of Solution Explorer.

  2. In the list of .NET Assemblies, select System.Data.SqlServerCe, and then click OK. If System.Data.SqlServerCe is not listed, follow these steps:
    1. In the Add References dialog box, click Browse.
    2. Navigate to the following folder: %Program Files%\Microsoft SQL Server Compact Edition\v4.0\Desktop.
    3. Select System.Data.SqlServerCe.dll, then click OK.
    The list of references in Solution Explorer now includes System.Data.SqlServerCe and your project can use this assembly.
    Note Note
    If your project uses the Entity Framework, repeat the same steps to add a reference to System.Data.SqlServerCe.Entity. You can add System.Data.SqlServerCe.Entity from list of .NET assemblies, or you can browse to %Program Files%\Microsoft SQL Server Compact Edition\v4.0.

  3. In Solution Explorer, right-click Form1.cs or Form1.vb and select View Code.
  4. At the top of the code for the form, add a directive to use the System.Data.SqlServerCe namespace. If you use the Entity Framework, add a directive to use the System.Data.SqlServerCe namespace. For a Tablet PC application, also add a directive to use the Tablet PC API:

    • C#
      using System.Data.SqlServerCe;
      using System.Data.SqlServerCe.Entity; 
      using Microsoft.Ink;
       
    • Visual Basic
      Imports System.Data.SqlServerCe
      Imports System.Data.SqlServerCe.Entity
      Imports Microsoft.Ink
      

No comments:

Post a Comment

Note: only a member of this blog may post a comment.