Offline application - database - c#

I have a problem with in choosing a database for desktop applications.
The application will work offline, and require a relational database.
My first idea was to create a strong typed dataset and keeping data in xml. But this is not a safe option.
The second idea is to place the SQL Express on computer, but it will be a exhausting.
Which option should I use? Maybe you have other ideas?

You can either use SQLite with SQLite-NET or SQL Server Compact Edition for an offline database.
Quick edit: here and here is a comparison of SQL Server CE vs SQLite.

You should use standard *.mdf in-file-database with EF using LINQ. Client won't need anything other than .NET installed on his machine.

Related

Best way to create database application in C#

I'm wondering what's the best way to create an database application using VS C# 2010 Express Edition and I have two questions:
What should I choose Microsoft SQL Server 2008 or SQL Server Compact
3.5? 2008 seems to be more complicated to install on user's desktop. If I am right, to use Compact you only need to install this
server and after that application is just able to use database
file.
What should I include into my package, .dll file will be enough or do I need whole for example Sql Server Compact installer?
You may use LocalDB from new SQL Server 2012 Express. I thing it's ideal for desktop apps. More info at MSDN and SQL Server Express WebLog.
Just to add, might help...
I'd suggest to use NuGet to download / install EntityFramework (type it in there and you'll get a list).
You have two versions, one regular flavor and one for compact edition.
http://nuget.org/packages/EntityFramework/4.3.1
http://nuget.org/packages/entityframework.sqlservercompact
And with that you'll get a basic 'framework' for dealing with databases as well (you'd need just to install the SqlCE (suggest 4 as is newest)) - NuGet installs the dll-s needed.
You can use 'model first' approach with EF (entity framework) to create Db first,
or even better use 'code first' approach - to create Db automatically from your code, classes.
That'd take care of creating new Db etc.
I think that's the easiest way to 'start up' with a new Db. And CE as well.
CE (compact) is a good choice - but watch, it has certain limitations comparing to the standard server SQL (express or standard etc.). E.g. you cannot use I think xml fields, and some other things, stored procedures, views etc. (If I'm correct and remember from before).
Also depends on what you want to make and where to deploy. Desktop doesn't mean that CE is best solution (depends on many details).
hope this helps
MSDN has some documentation on how to deploy SQL Server Compact with your app. It's indeed possible to both install it separately, or bundle it with your application, which is probably what you want.

WPF and local database, which one to choose?

I am working on WPF application, and now I have to choose which database to use. It will be local database.
I am thinking about SQLite, but I am not sure. I am not sure how much data my database will contain, maybe a lot, it depends on users use of application. In that case maybe SQLite is not good solution.
Maybe it is best solution to get use Microsoft SQL Server Express.
I would choose the MSSQL Express Edition because its the most well intergrated with .Net. And if you need to upgrade to Standard Edition its fully compatible you just upgrade it without change anything.
I recommend Microsoft SQL Server Compact Edition.
If you want to go with open source databases to cut down the cost MySQL is the ideal solution. it's competent to the MSSQL Server and one of the top most open source databases.

Database engine for a desktop application in C#

I need a lightweight database engine for a desktop application. The application is not data centric, although it needs some persistent data. Which one would you use MS SQL Server express edition or SQLite?
EDIT
Is SQL Server Compact edition free? If it is the case, what about SQLite vs SQL Server Compact edition to develop this kind of application?
Definitely NOT Sql Server Express. That's a server class engine. You want an in-process engine. In that regard, SQLite is fine. So is Sql Server Compact Edition. Both are free and either should be adequate for your needs.
If you're working with C# and Visual Studio simply right-click on your project and select "Add Item..." and in the dialog select the "Local database", this will create a SQL CE (Compact Edition) database. It's got most of the functionality of SQL Express/Server as far as tables, data types, views but doesn't allow stored procs. It also works with Linq-to-SQL so it's a snap to integrate.
Go with SQL Server Compact - you get to use LINQ that way, which itself is worth the effort.
While SQLite is an option, you'll need to get an ORM layer, and the performance gain will be minimal / non-existent compared to SQL Server.
Firebird is a well known database and support the latest Microsoft framework
SQLite, especially if it's single-user. One data file and one DLL.
If its a single user system you want to look at MS SQL Server compact edition not Express (see here: http://www.microsoft.com/sqlserver/2008/en/us/compact.aspx )
Compact Edition is an embedable database similar to SQLite.
Unfortunately I can't make a recommendation either way.
What about MS SQL Server Compact?
Some love for one of the up and comers in the .NET embedded db world -- VistaDb. The license is a bit more restrictive than Sql Server Compact (free to single developers only), but its a 100% managed DB with xcopy deployment and has VS tool integration.
Be aware that if you use SQL CE along with EF, you will have to generate your own id key, because SQL CE does not support multiple query.
i.e:
insert -> select key for the entity -> not good
generate and id key (GUID or something else) add it to your entity and then insert -> good
Defo SQL lite, although it has some restrictions/features that you should be aware of
if your need is data centric, what you really need is a file, if you need transaction (ACID) then your need is (rdbms) database.
Otherwise you'll have issues when up scaling.
If it's not a lot of data, and you don't need to run complicated queries (although LINQ can), why not use an XML Dataset? That way it's platform independent (could run on Linux with Mono) and doesn't require the user to install extra resource hogging software.
I use XML Datasets extensively for applications that require persistent data storage of small amounts of information. If it's only a few variables, you can also use a settings file, and it will be stored either per application or per user depending on your choices.
Think about overhead for your end users ... SQL Server Express still takes up resources, takes time to start up on a reboot and so on. For a small amount of single-user persistent data I would go with SQLite. Unless you're doing serious binding and so on you won't need an ORM between you and it.

C# and MySql integration

How well does C# integrate with MySQL ?
I am planning to write a small desktop application that connects to a Database and displays records. Is C# and MySQL a good combination ?
Should I use Java Swings and MySQL ?
Thanks in advance
Yes, it is. You can use MySQL .Net Connector as mentioned.
Or better, you use ORM ( such as NHIbernate) to abstract away the database vendor. I use NHibernate with MySQL in my C# application and it works well.
As Ralph Stevens suggested, you'd better go with SQL Server 2008 Express. Visual Studio 2008 integrates neatly with it and can generate Linq To Sql plumbing code right off the database. With a few clicks you are ready to handle the database in every way imaginable.
If you code ASP .NET, there is an added benefit: The mdf file that contains the actual database information can be stored in the App_Data folder and that goes with the project itself rather than the database engine. That comes in handly when you distribute the code to coworkers.
MySQL would work just as well with its .NET Connector but you will lose the visual benefits.
They integrate quite well. You can use ODBC, or better yet, the new MySQL .Net Connector.
May be this links be use full for you, was for me, when I started :)
windows-programming.suite101.com and
bitdaddys.com
How big is your database requirement? .NET works much better with SQL Server. SQL Server Express can go up to 4 Gigs of data and it's free. It meets the requirements of most small to medium apps. I suggest SQL Server Express.

Single-user database options

I'm going to be writing a Windows application using the .NET framework and C#. The application will need to store relational data which will be queried, joined and processed.
Previously I've done this using SQL Server, but that is a total overkill for the application I am now making.
What's the simplest, easiest way to store relational data in my application? If I was on a Mac, I'd be using SQLite. What's the .NET equivalent?
If you are using VS 2008 and .NET 3.5, you can use SQL Server Compact Edition. It's not really a server at all, it runs in-proc with your app and provides a basic SQL database. The databases themselves are a single .sdf file and are deployed with your app. Since it's part of the framework, it also means there's no additional installation. Actually, It's not actually part of the framework, but it's easily redistributable. I'm using SQL Server CE for a personal project I'm currently working on, and it's turned out great so far.
SQL Server Express is what you want. It's free IIRC and easily scales into full-blown SQL Server when required.
Why cant you use SQLite? It works on windows.
SQLite Quick start.
Also see here for getting it to work with .NET http://web.archive.org/web/20100208133236/http://www.mikeduncan.com/sqlite-on-dotnet-in-3-mins/
So you could use SQLite if you wanted to but perhaps as others have pointed out SQL Express is a better option as you can upgrade to a full server if you need to in the future. Although from what you wrote i don't know if that's likely.
Sqlite is definitely the best option for embedded database for application storage.
It is free fast and reliable.
Sql Server Compact Edition (*.sdf files). Small enough for Smartphones but also available on the full platform. The .net 2 version was called Sql Server Mobile.
Here is a comparison between Compact and Express.
I haven't used it yet but if I was making a windows application and needed functionality similar to this I would use the built in windows database that's already on every single box of windows.
http://www.codeplex.com/ManagedEsent
You can use SQL Lite with .NET. In fact, if you are willing to keep your code so it can translate to mono, which encompasses most 2.0 (3.5 still upcoming), you can run your code on the Mac, as well, if you stick with SQL Lite:
http://mono-project.com/Main_Page
It really depends on how much bang you need. SQL Express, which has been mentioned numerous times in this thread, is SQL Server. It has some restrictions over full blown SQL Server, but it is the full SQL Server engine, so it is not a lite version, unless you think restricting a database to 4 GB makes it light. If you need heavier services like some Reporting, some message queueing (service broker), then SQL Express 2008 is your creature.
For lighter in the MS world, you can go with SQL Compact. As with SQL Lite, it is limited in scope, but you stated you need a lightweight database.
If you are really familiar with SQL Lite, I see no reason not to head that direction. Add a factory on top of your database access, just in case you change your mind. Then you will not have to rip up your entire app to switch databases.
Microsoft JET Blue.
If not sqlserver express, You may want to conisder Microsoft SQL Server Desktop Engine ( scaled down version of sqlserver) which is free in most cases. or MySQL which is also free. I'prefer mysql.
SQLite
Firebird
MySQL Embedded
I would say Microsoft Access. You need a licence though ...

Categories