Click here to Skip to main content
15,922,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Does anyone have any advice on why when I execute a program in Visual Studio 2012 my SQL Server CE local instance keeps losing connection? It's connected while I'm working in designer or code-behind, but when I execute the program to run it, I see a red X next to the database instance.

Heads up, I got it working.

On VS2012 Add Reference, you have to browse and look for;
C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v4.0\Desktop
and select,
Note, the above was for SQLCE 4.0. More details below.

Import it on your project and you're good to go. Just make sure you're importing the right version for the database you are using.

C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v4.0\Desktop

C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v3.5\Desktop
Share this answer
joshrduncan2012 18-Sep-12 13:53pm    
Ok, thanks! I'll try that now.
joshrduncan2012 18-Sep-12 13:57pm    
How do you import it after adding the reference?
Aron Jay 18-Sep-12 14:06pm    
VB: Imports System.Data.SqlServerCe
C#: Using System.Data.SqlServerCe;
Aron Jay 18-Sep-12 14:07pm    
VB: Imports.System.Data.SqlServerCe
C#: Using System.Data.SqlServerCe;
joshrduncan2012 18-Sep-12 14:07pm    
Did you get the CE database connection to stick after you executed the program?
Same here. Even after I do Imports System.Data.SqlServerCe, sqlceconnection, sqlcecommand and others are not available.
Share this answer
joshrduncan2012 18-Sep-12 13:02pm    
You need to connect the CE database first before importing the library for it. Without the CE db in the project, you won't get sqlceconnection, et al.
Aron Jay 18-Sep-12 13:06pm    
I did. Previously I was fine with 3.5 but upon updating Visual Studio 2012 Express and SQL CE 4.0, it seems that 3.5 SQL CE database is not supported on design time. So I created another database (4.0 SQLCE). There's something wrong with either VS2012 or .net 4
Aron Jay 18-Sep-12 13:07pm    
Btw, my SqlServerCe.dll was from GAC folder on Microsoft.Net inside Windows folder.
Aron Jay 18-Sep-12 13:08pm    
If this will never work I might consider just installing the required 3.5 components for visual studio 2012 to use my old SQL CE 3.5 database.
joshrduncan2012 18-Sep-12 13:10pm    
I'm starting to believe you. :( How are you installing the 3.5 components? .net 3.5?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900