Click here to Skip to main content
12,697,340 members (27,281 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C#
I am trying to connect a database using C# . in a visual studio 2010.

this is the code To set up a SqlServerCe connection variable
System.Data.SqlServerCe.SqlCeConnection con; // outside the form load
con = new System .Data .SqlServerCe.sqlCeConnection(); //inside the form load

I get an error saying:
sqlServerCe does not exist in the namespace.

What I know is that i need to add an assembly reference. How do i do that?

please help.

NB:
this assembly (SqlServerCe) is part of SQL Server Compact Edition and not part of Microsoft .net Framework. so i have to add it manually in VS 2010 professional. how do i add it manually?
Posted 2-Apr-13 23:48pm
Updated 3-Apr-13 0:53am
v6
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

See here: http://msdn.microsoft.com/en-us/library/system.data.sqlserverce.sqlceconnection(v=vs.80).aspx[^]
Quote:
Namespace: System.Data.SqlServerCe
Assembly: System.Data.SqlServerCe (in system.data.sqlserverce.dll)

Here described is how you can add a reference: http://msdn.microsoft.com/en-us/library/wkze6zky(v=vs.80).aspx[^] to an assambly. This one should be in the first category.
  Permalink  
v2
Comments
Levy Mpyana 3-Apr-13 5:52am
   
this assembly (SqlServerCe) is part of SQL Server Compact Edition and not part of Microsoft .net Framework. so i have to add it manually in VS 2010 professional. how do i add it manually?
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

i have found an alternative solution.

To connect to the sql database using C# in Microsoft Visual studio,you have to amanually add the sqlSeverCe name reference manually.
that is you click on Project>>>Add Reference

a window pops up, click on the browse tab.

browse to C:\Program Files\Microsoft SQL server Compact edition\v3.5\Desktop

then double click on the System .Data .SqlServerCe file,
press OK.
  Permalink  
Comments
Richard MacCutchan 3-Apr-13 7:03am
   
This is not an alternative solution, it is the standard method of adding references to a project; one of the basics of building in Visual Studio.
Zoltán Zörgő 3-Apr-13 7:06am
   
Richard is right. You have not read the second link I have given. This is also described there.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.170118.1 | Last Updated 3 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100