views:

200

answers:

5

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)
    {
        DataSet mySet = new DataSet1();
        DataRow oOrderRow = mySet.Tables["tblPeople"].NewRow();
        oOrderRow["name"] =nameTextBox.Text;
        mySet.Tables["tblPeople"].Rows.Add(oOrderRow);

    }
+4  A: 

Try SQL Server Compact edition.

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

Mehrdad Afshari
won't you need SQL Express installed on the device?
hunter
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.
Mehrdad Afshari
can you use LINQ2SQL with mobile applications? i read somewhere you could not?
Andi
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.
Mehrdad Afshari
+1  A: 

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.

Marcom
+1  A: 

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.

lomaxx
A: 

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.

Andi
A: 

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.

Barry
what are the pros and cons of it over sqlce?
Andi
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.
Barry