Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C#
System.Data.SqlServerCe.SqlCeConnection con; // outside the form load
con = new System .Data .SqlServerCe.sqlCeConnection(); //inside the form load

I get an error saying:
HTML
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
Updated 2-Apr-13 23:53pm
v6

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.
 
Share this answer
 
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?
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.
 
Share this answer
 
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)



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