[英]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. 我已经为Windows Mobile 5编写了一个基本的应用程序。
It is using visual studio 2008 and c# .net 它使用Visual Studio 2008和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 . 尝试使用SQL Server Compact Edition 。
It's very similar to the "real" SQL Server from client perspective. 从客户端角度来看,它与“真实” SQL Server非常相似。 It supports easy data access with LINQ.
它支持使用LINQ轻松进行数据访问。
You can create an sqlce database if ur using vs 2008 using sqlce 3.5 would be the easiest. 如果使用sqlce 3.5的vs 2008最简单,则可以创建sqlce数据库。
or if you dont have a lot of data store all your information in an xml file. 或者如果您没有很多数据,则将所有信息存储在xml文件中。
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 .
对于Windows Mobile,我会考虑使用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. 我最初尝试设置SQL Compact数据库,但没有意识到那是我在做什么,但是我一直收到错误消息。
If you are receiving errors when trying to create a new sql ce database file (In VS2008-- Add Item->Data Tab->SQL Database) 如果在尝试创建新的sql ce数据库文件时收到错误(在VS2008中-添加项目->数据选项卡-> SQL数据库)
Make sure you have SP1 for visual studio as there are a few known issues. 确保存在Visual Studio SP1,因为存在一些已知问题。 You can get SP1 here
您可以在这里获得SP1
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. 我建议使用SQLite而不是sqlce并使用SDF文件。 I use the wrapper DLLs from PHX software ( http://sqlite.phxsoftware.com/ ).
我使用来自PHX软件( http://sqlite.phxsoftware.com/ )的包装DLL。
From sqlite.org: SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. 来自sqlite.org:SQLite 是一个软件库,可实现自包含,无服务器,零配置的事务型SQL数据库引擎。 SQLite is the most widely deployed SQL database engine in the world.
SQLite是世界上部署最广泛的SQL数据库引擎。 The source code for SQLite is in the public domain.
SQLite的源代码位于公共领域。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.