Click here to Skip to main content
Rate this: bad
good
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 22:48pm
Edited 2-Apr-13 23:53pm
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 at 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 at 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ő at 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
0 OriginalGriff 428
1 Sergey Alexandrovich Kryukov 253
2 PhilLenoir 115
3 RajeeshMenoth 110
4 Peter Leow 100
0 Sergey Alexandrovich Kryukov 6,465
1 OriginalGriff 5,926
2 CPallini 2,473
3 Richard MacCutchan 1,687
4 Abhinav S 1,540


Advertise | Privacy | Mobile
Web04 | 2.8.140821.2 | Last Updated 3 Apr 2013
Copyright © CodeProject, 1999-2014
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