6

I'm working on a simple WinForms app that uses an .sdf database to store data. I saw this interesting post on how to handle multithreaded access, which seemed useful. Problem is, I can't find the System.Data.SqlServerCe assembly. I installed the Sql Server Compact 3.5 SDK, but that reference still doesn't show up in my .NET assemblies list when I go to add the reference. What am I missing?

I'm using Visual Studio 2010 Ultimate on Windows 7.

Turbot
  • 5,095
  • 1
  • 22
  • 30
Stephen Collins
  • 3,523
  • 8
  • 40
  • 61

4 Answers4

8

Go to "Tools" and select "Choose Toolbox Items..." and select .Net Framework components and see if any of the SqlServerCe components shows up, then select one of the System.Data.SqlServerCe components, if you then add it to your form it will add the reference to your project.

enter image description here

Rich
  • 3,928
  • 4
  • 37
  • 66
Mark Hall
  • 53,938
  • 9
  • 94
  • 111
  • For myself, I can only seem to see SqlConnection, SqlCommand, SqlCommandBuilder - so no SqlCe... items. Is there any define with my items not being SqlCe... ? thanks – Sambuxc Dec 21 '14 at 15:23
  • 1
    @Samuroid did you install the [SQL Server Compact SDK](http://www.microsoft.com/en-us/download/details.aspx?id=10070)? http://stackoverflow.com/questions/10747518/sql-server-compact-edition-4-0-sdk – Mark Hall Dec 21 '14 at 15:29
  • @MarkHall Yes I believe I have. I have the Microsoft SQL Server Compact Edition directory under ProgramFiles – Sambuxc Dec 21 '14 at 16:31
  • @Samuroid you will need to click the browse button and go to the directory and select the proper dll per compentent_tech's answer – Mark Hall Dec 21 '14 at 16:57
  • @MarkHall thanks, I managed to get it working now :) However upon trying to access the data in my tables I get this error message, "Database file may be corrupt..." – Sambuxc Dec 22 '14 at 08:07
  • You probably should ask that as a question. – Mark Hall Dec 22 '14 at 08:09
1

I believe that you need to browse to the assembly in order to get it included.

competent_tech
  • 44,465
  • 11
  • 90
  • 113
0

have a look at this post on MSDN : How to find correct "System.Data.SqlServerCe.dll" in desktop project?

BizApps
  • 6,048
  • 9
  • 40
  • 62
0

Adding my database as a Data Source solved the problem for me. (Shift + Alt + D) then Add New Data Source knowing that my .sdf database is already connected with my project via Data Explorer.