0

I want to connect a SQL Server CE database file (.sdf) to a web application. Once I run it I'm getting the following error. And I have no idea what's wrong.

Error says

Compiler Error Message: CS0234: The type or namespace name 'SqlServerCe' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)

But once I add

using `System.Data.SqlServerCe;

no errors show in IDE but once I compile it I'm getting above error.

using System;
using System.Collections.Generic;
using System.Data.SqlServerCe;
using System.Linq;
using System.Web;

public class LocalDbConfig
{
    private string dbPath;
    private SqlCeConnection con = null;

    public LocalDbConfig()
    {
        dbPath = "Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "\\App_Data\\Root.sdf";
        con = new SqlCeConnection(dbPath);
    }
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

Check that you added the reference to the system.data.sqlserverce.dll in your project

Alexandr Mihalciuc
  • 2,537
  • 15
  • 12