Single-user database options - c#

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 ...

Related

.Net Best sql server to use

HI, I'm trying to create a simple database for my C# .NET application. It's easy enough to create a db and to run it locally, but I was wondering which is the best free one I should Use? Furthermore, I would also like the application to be easily deployable on multiple PCs (each with their own local db instance). What is the best tool for me to use?
SQLite is very popular.
http://www.sqlite.org/
I would also add they have fantastic support across many platforms and uses:
http://www.sqlite.org/whentouse.html
Take a look at the latest SQL Server Compact Edition. It's designed to be embedded so you can easily deploy with the right files added to your install / copy setup.
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=0d2357ea-324f-46fd-88fc-7364c80e4fdb&displaylang=en
Postgres if you need this to be a serious solution, SQLite if it's a lightweight concern.
For my money, Nhibernate support is the important question.
If you're using .Net, why not use SQL Server Express Edition?
The Microsoft answer is SQL Server CE (Compact Edition): http://www.microsoft.com/sqlserver/2005/en/us/compact.aspx
There is an isntaller, but it can also be deployed just by including a few DLLs.
The obvious answer should be the express edition of SQL Server :
http://www.microsoft.com/express/Database/
Personally I just use microsoft access most of the time for simple stuff.
Note that may users are suggesting SQL Server Compact Edition. It could be useful to know the difference. CE is much more limited, but easier to deploy. Sounds like CE is the better choice for your application.

How to start with database?

i have just started using visual studio 2008.I am working on c#.
I want to add SQL database particularly LOCAL database (.sdf) to my project and want to use queries which will save data in database and fetch some data from database and which will display and will perform different function.
So, if any body can give me any small tutorial or link that what are various types of databases i can use along with visual studio and and how will i be able to use it.
Any general tutorial will do.
Thanks a lot.
Regards,
Don't use .sdf databases.
I've worked with it but it was confusing. I was not able to use WHERE statements....
Use SQLite instead.
That is THE Solution.
Download SQLite here
Another tutorial
I recommend you the use of SQLite
Not sure why Gergen was unable to perform where statements. One issue I had with Compact edition was that I couldn't create stored procs or views. I don't have much experience with SQL Lite, so I can't give an opinion on that.
If you are doing web based stuff (i.e., asp.net), I found the following series a good introduction to database stuff: Data Access Tutorials
As for what database to use, as long as there's a provider for it, working with it via ADO.NET (or entity framework, or whatever) should be similar. If you are just starting, I'd probably recommend staying with the Compact Edition since most examples/tutorials you'll see will involved SQL Server.
For simple Local SQL database stores, there are quite a few solutions. A good full comparison can be found on from Wikipedia
SQL Express 2008
Out of process, runs as a windows service, supports stored procedures and views and does pretty much everything SQL standard does with few limitations. 50MB install.
Ideal for anything but large SQL deployments.
Loads of how to guides for SQL Express
SQL Compact Edition 3.5 (.sdf files)
In process, the code for accessing the database runs within the same process as your application. Ideal for embedded systems (point of sale, ATM, in-car systems etc...). Microsoft's equivilent to SQLite. Very small install (easy to deploy with app).
Getting started guide for SQL Compact Edition and a load of HowTos to get you going
SQLite
The non-Microsoft answer to an in process database. Pretty much the same functionality as SQL Compact Edition apart from it's a smaller install (300kb for SQLite vs. 2MB for SQL Compact edition), it supports larger database files (32TB for SQLite vs. 4GB for SQL Compact edition).
SQLite getting started article
Connecting to Microsoft SQL Server 2008 from Microsoft Visual Studio 2005 and 2008
http://msdn.microsoft.com/en-us/library/s4yys16a(VS.71).aspx
I've never built anything using SQL Lite so I can't say much for it. I have, however, built several commercial applications using Compact Edition and haven't had any serious issues.
You can't batch commands with CE and the syntax is the same as Sql Server (with many missing features, but the most commonly used features are there and I've never had a problem without a work around of some sort).
I've really only used it as an "offline" database in an application for a company that dispatches repair technicians. The applications run on netbooks and download their data from a MySql database whenever mobile connectivity is available so they still have access to their work when they have no mobile coverage.
Due to it being so similar to SQL Server, Compact Edition would probably be an easier starting point. Since you're using a local database file you probably won't hit the 4GB limit (with very little pruning my mobile databases rarely exceed 20MB) - and if you ARE hitting that limit you may want to consider using a service based database (like Express) instead.

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.

What are some good sql databases for home Vista computer?

I have been trying for a long time to get SQL Server Express on my computer to practice my C#/SQL with and I still haven't gotten it to work.
Are there other programs I can use to setup an SQL database to practice with? If so, which are the best ones for Vista?
EDIT:
To be clear I am not new to SQL programming, I just haven't done any in a while and want to stay fresh. So I would like something that has most of the features of forms of SQL I would use professionally.
MySQL or Postgresql are both full fledged DB's and good for education/experimentation. You can also check out Oracles free version.
SQLite is good if you need something fast, small and powerful... its a fast download also.
SQLite
SQLite with C#
What aren't you getting to work for Sql Express. It works on Vista. I use it on a daily basis. It no longer comes standard with a "northwind" database, but you an download the AdventureWorks DB. Can you be more specific about "I still haven't gotten it to work"?
I've also heard good things about firebird
Although I still believe that C# and SQL Express is the best way to go.
SQL Server Express generally should be the natural choice for practice with .NET and C#.
If you have no prior experience in working with SQL Server and its Express version one most confusing thing is that SQL Server Express is not installed as default instance, but as SQLEXPRESS instance. So you have to use "Data Source=.\SQLEXPRESS" in your connection string.
In case you can not overcome issues with SQL Express you can try Postgres, but you will need to download and use .NET Data Provider for Postgres.
I preferr Firebird its a madure BD and its O.S. very stable btw.
http://www.firebirdsql.org/
and try ibexpert for manager this bd.
http://ibexpert.net/ibe/
Both Oracle and IBM offer offer versions of their flagship databases for free in a similar manner to SQL Server Express. Both are excellent products if you wish to play with a 'real' database system.
Oracle 10g Express
IBM DB2 Express
Postgres is also well worth considering as it is also a 'real' relational database, having originally started as the much respected Ingres RDBMS in the 1980s. However Postgress until recently was Unix-based and I've never found it particularly reliable installing on Windows.
Personally I would not recommend MySQL for your scenario - although the latest edition can finally be described as a RDBMS having evolved from what really was a collection of flat files with a limited SQL query interface it's peculiarities probably mitigate against it's use as a learning tool unless you are actually focused on MySQL.
There are a number of other less popular RDMSs you could consider. Firebird has always been something of a favourite of mine as I used to code a lot of Delphi, and SQLite is a joy to work with in many circumstances. It's also a pity you cannot use SQL Server Express as the SQL Server product range is simply the most solid product Microsoft produces and usually my database of choice on anything but the smallest, largest or most unsual installations
Vista DB is quite a nice lightweight managed flatfile database (not related to Windows Vista).
For something very simple look at sqlite It supports most SQL syntax and stores it's database in a single file so has very little setup. You'll need an ado.net data provider for it which you can find here Although it isn't a good choice for multi user systems with lots of data it should be fine for an introduction to database programming.

Categories