简体   繁体   中英

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

    }

Try SQL Server Compact edition .

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

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.

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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM