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);
    }
}
0

1 Answer 1

0

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

Sign up to request clarification or add additional context in comments.

1 Comment

I already add that references in project

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.