Home » SQL Server

Integration of System.Data.SqlServerCe DLL

I am trying to use the SqlServerCe DLL in a Windows Forms app being built in Visual C# 2010 Express.  I notice that this DLL is not integrated with other .NET 3.5 and 4.0 DLLs in the Program Files Reference Assemblies on my system (Windows XP), but is rather isolated in the Program Files => SQL Server Compact Edition directory.  While that is not an inherently big problem as far as I can tell, it does mean that System.Data.SqlServerCe doesn't always show up or show up where you would expect it in various Visual Studio dialogue boxes.  For example, when doing an Add Reference and using the .NET source for DLLs, the SqlServerCe DLL does not show up in alphabetical orger with the other  System.Data.* namespaces.  It took quite awhile before I stumbled on it, which triggered the realization that it is not intergrated with the other .NET components.  It seemed to me there have been other times in researching SqlServerCe that I wasn't finding things when I was expecting (recognizing that I have limited experience with this stuff so far).

Three questions: (1) Is using System.Data.SqlServerCe still a proposed means to interface with SSCE programmatically (using Visual C# 2010 Express); (2) Might I have done something to (inadvertently) cause SqlServerCe to install outside the bulk of .NET (I frankly can't remember how I got SSCE 3.5 on my machine in the 1st place); and (3) Is there an easy way to fix it?  On the latter question, I notice there are FrameworkList.xml files for v3.5 and v4.0 in my Reference Assemblies, containing a list of all the DLLs packaged with those .NET releases.  Would System.Data.SqlServerCe have to be added to those and, if so, where would I get the Public Key Token?  Are there other manual inegration steps I would also need to take?




4 Answers Found


Answer 1

Hi Steve Rehling,


Is using System.Data.SqlServerCe still a proposed means to interface with SSCE programmatically (using Visual C# 2010 Express)

Could you please explain a bit more?

This assembly is part of SQL Server Compact Edition. If we want to connect to database of SQL Server Compact Edition via .net, this assembly is required.


Might I have done something to (inadvertently) cause SqlServerCe to install outside the bulk of .NET(I frankly can't remember how I got SSCE 3.5 on my machine in the 1st place)

This assembly is installed as part of SQL Server Compact Edition. It is no part of .net.

SQL Server Compact Edition 3.5 SP2 is installed during installation of Visual Studio 2010.


If anything is unclear, please let me know.


Answer 2

Tom - Thx for the reply. 

My 1st question about SqlServerCe being mainstream stems from instances where I tried to learn about or use it in ways that I thought should work but didn't (at least given what I was trying to do).  Unfortunately, I didn't keep a list of when that happened (I will start now) and can recall/recreate only one example.  In using the Object Browser in Visual C# 2010 Express, a search for SqlServerCe produces "no results," regardless of what I set as the Browse components (even "All Components").  If I add a Reference to the DLL using Solution Explorer => Add Reference (where SqlServerCe does show up under the .Net tab), then the search shows the result.  Perhaps I'm trying to use Object Browser in a way that's not intended in this example, but that doesn't seem right to me.

As I said, I'll start to keep track of places where my attempts to use SqlServerCe doesn't work the way it seems to me it should and post them when I have a few.  In the meantime, I'd appreciate any perspective you have on the Object Browser example above.



Answer 3

Hi Steve,


As I said above, this assembly is part of SQL Server Compact Edition and not part of Microsoft .net Framework. In order to see it in Object Browser, we have to add it manually. Please see the steps below:

1.       In Visual Studio, please press CTRL+J to display Object Browser

2.       From the dropdown list, please choose “Edit Custom Component Set…”

3.       In Edit Custom Component Set window, please switch to Browse tab

4.       Locate to the location of this assembly
we could found it in the following folder:
c:\Program Files (x86)\Microsoft SQL Server Compact Edition\v3.5\Desktop\System.Data.SqlServerCe.dll
c:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Desktop\System.Data.SqlServerCe.dll

5.       Double click it to select it

6.       Click OK


If anything is unclear, please let me know.


Answer 4

Thanks, Tom.  Your responses have cleared up the mystery.

My conclusion from all this is that MS ought to consider better integrating SQL Server Compact Edition (SSCE) into VS since it is the recommended dbms for Windows apps that use local databases (which would seem to be a prevalent app architecture).  I know I've spent a lot of time as a newbie trying to discover how it works.  So far, the list of changes I would recommend include the following:


Object Browser:  to see SSCE objects in Object Browser, you have to select “Edit Custom Component Set” and then “Browse” to the SSCE Program Files to select the SSCE DLLs versus Object Browser containing a Browse pulldown menu item for SSCE (and perhaps other SS variants if they too aren’t seamlessly integrated).  It doesn’t seem right that SSCE has to be treated as a “Custom Component Set.”Using Statement: you have to manually add a "using System.Data.SqlServerCe" statement to the code even after seemlessly adding a local database via Solution Explorer. Add Reference:  when Adding a Reference to the SSCE DLL in Solution Explorer, the Add Reference dialogue box .NET tab does not show the System.Data.SqlServerCe DLL in alphabetical order with the other (.NET) DLLs.  For someone new to using VS and .NET this causes confusion and lots of wasted time trying to figure out why it’s not there (when it fact it is, only out of order).


<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure