Sql server compact for windows app using visual studio 2010 - c#

I am working on windows app where i need to use sql server compact . I tried various articles for using it in visual studio 2010
Private Installation for SQL Compact
Working with SQL Server Compact in Visual Studio
but didn't get any satisfactory answers .Please suggest me best solution available for this .

If you use the nuget package (http://nuget.org/) you can simply look it up and install it. Otherwise you just copy the sql server compact dll's to your exe directory and include System.Data.SqlServerCe.dll

There are various different ways to interface with a database. As an OO framework .net has various abstractions for database access. The main ones are (vanilla) ADO.NET (not recommended), EntityFramework, nHibernate and LinqToSQL (not recommended). They will all work with SQL CE very well.
Given what you have described so far I would recommend EntityFramework CodeFirst SQL CE. Scott Gu has a good blog on an old version of this tech. I would start by just installing the premade nuget for SQL CE EF.

Related

Service based database vs SQL Server Compact vs LocalDB?

My goal is to create a stand-alone C# Windows form application with 2-3 tables that will be installed on client machine with a installer file. And I don't want to install SQL Server 2008 software on client machine, I'm using Visual Studio 2013 C# for development.
My options are SQL Server Compct 4.0 but I don't see Visual Studio 2013 has inbuilt support for that, when I add new item to project I don't see Compact (.sdf) file option there.
I've installed third-party SQL Server Compact Toolbox so I can create .sdf file and connectivity but I believe Microsoft is not giving support for compact db now.
I can see service-based database (.mdf) file which is actually a LocalDb\\ something.
So what should I use if I don't want to install SQL Server 2008 on client but want to have db
at client software?
You should mostly base your choice on your target platforms and the level of SQL Server functionality you expect.
Target Platforms:
LocalDB does not support older versions of Windows (e.g. Windows XP) or WoW. Toad World's LocalDB overview has a good breakdown of its target-platform restrictions.
SQL Server Compact Edition has very few target-platform restrictions. Check out its download page under "System Requirements" for specifics.
Functionality:
LocalDB better approximates SQL Server Express functionally. SQL Server Compact Edition has many functional limitations (e.g. no support for stored procedures).
MSDN's introductory overview of LocalDB explains many of the important functional differences between LocalDB and SQL Server Compact Edition; and the aforementioned Toad World LocalDB overview explains some of what (not) to expect from LocalDB functionally too.
Redistribution:
Both SQL Server Compact Edition (per the "Additional Information" section of its download page) and LocalDB (per SQL Server forums) are freely redistributable: so you should be okay with either with respect to fine print.
maybe SQLite would be an option? check out: http://www.sqlite.org/
it's just a DLL/Assembly you need to reference and it's pretty straightforward..

SQL Server CE distribution

I have spent several days trying to solve this problem with no luck and my requirements are really simple - I want to make an application with database which will work on most PCs (without DB server installed) and I want to use LINQ. For the compatibility reasons I want to use .NET framework 3.5 (every Windows 7 machine has it).
I have tried 2 ways: SQL Server CE and SQLite.
SQL Server CE
Although Visual Studio does not support LINQ for Compact Version of SQL server, I have found simple workaround - generating .dbml file using metal.exe tool from Visual Studio and then dragging it into project. My application works fine on my machine, but when I copy it somewhere else, it crashes. I have copied all dlls from C:\Program Files (x86)\Microsoft SQL Server Compact Edition\3.5 and tried 4.0 too. I think problem is that my app is not looking for dlls (references) inside its directory. I managed to get it work using DataSets (without LINQ), where I manually add reference to SQLServerCE and check CopyLocal to true. BUT when I use LINQ, there is no reference to SQLServerCE in project references and it is working. I don't know how to change it. Or is there a problem somewhere else?
SQLite
After long messing with SQL Server CE, I have tried SQLite. I am very disappointed how poor is SQLite support in .NET. I had to download older version of ADO.NET provider (newer versions does not add SQLite Database into my Visual Studio 2010 - I don't understand why but I googled that it is normal and I have to install old version and then replace it with newer). Then I downloaded dblinq (I have discovered that this project is dead later) and after some messing with dbmetal and dlls I get rid of errors in Visual Studio and compiled my application. But I can't run it, it always crashes on error 40 - like there was no SQLite server. Of course I have copied all dlls. I can't run it even on my development machine.
I am very surprised that it is nearly impossible to create simple database application in C# .NET which will not bother client with servers etc.
Please is there anyone who made SQL CE work with LINQ and mainly who made his app distributable?
I would suggest you try using the nuget Entity Framework for SQL CE package. It will download all the required assemblies to make it work.
http://nuget.org/packages/EntityFramework.SqlServerCompact/

DMS without installation having Entity Framework driver?

I'm looking for a database system to use with c#. I've mostly used SQL for now, but, this is a small applicaiton I'm gonna to create, which:
-Runs at max 1-2hours each day(so I don't want to have a SQL Server running all the time)
-Will be installed on an usb key(only requirement has to be to have .net 4.0 installed), so it has to be nomade.
What can you advise me? I search a little, but I don't how this kind of database are called.
You can look at the embedded version of Firebird
Firebird have more SQL function than SQLLite which also be a good choice but you can more easily to switch to a full version of the server
The embedded version is an amazing variation of the server. It is a
fully featured Firebird server packed in just a few files. It is very
easy to deploy, since there is no need to install the server. It is
ideal for CDROM catalogs, demos or standalone desktop applications.
Here you can check Entity Framework support
Well, i'd use a file-based "portable" database like:
SQLServer Ce 4.0
Sqlite (I used this provider in the past and it works well, but you have quite a bunch of options).

Webservice c# free database

I want to learn webservice development using c# and a free database. Could someone tell me what is the best free database solution to work with c#?
thanks
Microsoft have a free version of their SQL Server database which is SQL Express. Also they recently released a new Embedded Database which is worth checking out. MySQL and SQLite are other popular choices.
As far as web service development in .NET is concerned WCF is the recommended way.
While learning, just stick to the visual studio ide and utilize the integration with iis and sql express which should be already installed. web services in C# need iis (due to .net framework requirement for c#) plus the visual studio ide is easyily integrated with sql express. after you get some learning in, you can move towards installing and connecting to other databases like MySQL or PostgreSQL ect..
There is also sql express and sql ce
I use MySQL with c# and Entity Framework every day. It works great, and you won't be limited by the express edition of SQL Server that way.

How to create an SQL Compact 2008 application

How can I make a SQL Compact 2008 application for the desktop? I know how to connect to a .SDF file with SQL Management Studio 2008, but I can't figure out how to connect to it with my app. I have seen tutorials about this and I can see in the C# code they are referencing some special namespaces, but I can't seem to get it to work. What I did is download the Microsoft SQL Compact SDK but I get an error whenever I try to add references to any of the DLL's that came with it. Does anyone know where I can find the correct binaries for this.
Have you gone here and downloaded all the components listed (including the design tools)?
If you post the "error" you get it might be easier to diagnose your problem.
You need to download SQL Sever Compact 3.5.
Then you could create a LINQ2SQL model (dbml) using the sqlmetal tool that
comes with the .NET SDK (and Visual Studio). Currently it is not possible
to create LINQ2SQL classes for the compact framework inside Visual Studio,
but you will be able to view and edit them.
I haven't got much time now, as I really need to get going,
but I hope this gets you started.
PS: References in my project are System.Data, System.Data.Linq
and System.Data.DataSetExtensions
UPDATE:
As for the DLL's you are referencing... I don't think they are .NET assemblies
but native win32 DLL's intended to be used by C++ developers.

Categories