How do i create a database and access it for my windows mobile 5 app?

I have written a basic Application for windows mobile 5. It is using visual studio 2008 and c# .net I am currently trying to find a way of storing my customer names but im not sure what format is best for storing data directly on the device ( i dont need it to integrate with any servers or anything) I'm hoping someone here knows which direction i should be looking. I'm looking into the dataset object at the moment but doesnt seem to be saving anything? Here is a snippet of code i've been playing with.

 private void menuItem1_Click(object sender, EventArgs e)
asked Jul 19, 2009 at 13:35 10k 10 10 gold badges 65 65 silver badges 104 104 bronze badges

5 Answers 5

It's very similar to the "real" SQL Server from client perspective. It supports easy data access with LINQ.

answered Jul 19, 2009 at 13:38 Mehrdad Afshari Mehrdad Afshari 420k 92 92 gold badges 857 857 silver badges 793 793 bronze badges won't you need SQL Express installed on the device? Commented Jul 20, 2009 at 0:38

No, SQL Express cannot be installed on the device. SQL CE is a much smaller version version of SQL Express that you need to install on device. It's not a client/server system. The application just connects to the database file directly.

Commented Jul 20, 2009 at 6:27 can you use LINQ2SQL with mobile applications? i read somewhere you could not? Commented Jul 22, 2009 at 8:17

SocialAddict: You can use LINQ to SQL with SQLCE (it runs on the desktop too). .NET CF supports LINQ to DataSet but not LINQ to SQL directly. You can load data in DataSet and issue LINQ queries on it.

Commented Jul 22, 2009 at 8:44

You can create an sqlce database if ur using vs 2008 using sqlce 3.5 would be the easiest.

or if you dont have a lot of data store all your information in an xml file.

answered Jul 19, 2009 at 13:38 4,701 8 8 gold badges 55 55 silver badges 79 79 bronze badges

The dataset object is only a container for working with your data in code. To actually persist your data, you need to use a database. For windows mobile, I'd be looking at something like SQL CE.

You use datasets to represent data in memory and you use the database to store the data for your application to use.

answered Jul 19, 2009 at 13:40 115k 58 58 gold badges 147 147 silver badges 180 180 bronze badges

I originally tried setting up a SQL Compact database without realising that was what i was doing, but i kept receiving an error message.

If you are receiving errors when trying to create a new sql ce database file (In VS2008-- Add Item->Data Tab->SQL Database)

Make sure you have SP1 for visual studio as there are a few known issues. You can get SP1 here

I'm now continuing with my application and once it's finished i'll post a link to the solution file as i think it would be a very good simple example of a Mobile App with a database and a few forms.

answered Jul 22, 2009 at 8:32 10k 10 10 gold badges 65 65 silver badges 104 104 bronze badges

I would recommend using SQLite instead of sqlce and using SDF files. I use the wrapper DLLs from PHX software (http://sqlite.phxsoftware.com/).

From sqlite.org: SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain.

answered Sep 9, 2009 at 12:24 1 4 4 bronze badges what are the pros and cons of it over sqlce? Commented Sep 11, 2009 at 6:52

The pros are listed above, you need only to have the DLLs on the device and it will run, with SQLce you need run a CAB to install in on devices. Also those DB files can be accessed from any OS without a problem. Another big plus is the use of transactions. The cons. The "query analyser" software is not as professional as sql server. The database has no abilty to handle mulitple simualteanous users. The documentation is a not that straight forward. I maintain 3 procucts on many different devices (CE and mobile) and sqlite is the best db I have found.

Commented Sep 15, 2009 at 10:02