简体   繁体   English

创建我的第一个移动应用程序并将其连接到数据库

[英]Creating my first Mobile App and connecting it to a database

I have to create a Windows Phone 7 app as part of a research project. 作为研究项目的一部分,我必须创建一个Windows Phone 7应用程序。 The app needs to: 该应用程序需要:

  • Allow the user to login by connecting to an sql server database (stored locally for the purpose of this project) 允许用户通过连接到sql server数据库(为此项目而存储在本地)来登录
  • If login successful, return a list of products associated with the user (ie in product table where UserID=x) 如果登录成功,则返回与该用户关联的产品列表(即在产品表中,其中UserID = x)
  • User can click on an item in the list, and then add photos for that item. 用户可以单击列表中的一个项目,然后为该项目添加照片。 This can be done offline as well (using HTML5 offline storage) 也可以离线完成(使用HTML5离线存储)
  • When an internet connection is available again, user can click 'Upload' (or automatically synced, but not necessary) and the images are all uploaded to the Images table with the correct ProductID as Foreign key 当互联网再次可用时,用户可以单击“上传”(或自动同步,但不是必需的),并且所有图像均以正确的ProductID作为外键上传到了“图像”表中

Since this is the first time I am doing any mobile programming, I am not sure what is the best approach. 由于这是我第一次进行任何移动编程,所以我不确定什么是最佳方法。 I am especially unsure of how I am going to connect to the database. 我尤其不确定如何连接数据库。 I'm not really interested in learning Silverlight, so the app should use mainly HTML5 and javascript, I also am looking into JQueryMobile. 我对学习Silverlight 并不是很感兴趣,因此该应用程序应主要使用HTML5和javascript,我也正在研究JQueryMobile。

I have already installed PhoneGap and am trying it out, but my main concern is how to connect the app to the database as I am having trouble finding the 'proper' way of doing this eg using some kind of web service or directly through javascript (read it can be done but is not recommended). 我已经安装了PhoneGap并正在尝试中,但是我主要关心的是如何将应用程序连接到数据库,因为我无法找到执行此操作的“正确”方法,例如使用某种Web服务或直接通过javascript(阅读可以完成,但不建议这样做)。 If anyone could recommend or suggest a good approach of doing this that would be great! 如果有人可以推荐或建议这样做的好方法,那就太好了!

SqlServer is only available on the phone via LinqToSql which you need to expose via a service or a DAL. SqlServer仅在通过LinqToSql的电话上可用,您需要通过服务或DAL公开。 I dont think that its possible to make calls directly from Javascript to LinqToSql on the phone. 我认为通过电话直接从Javascript到LinqToSql调用是不可能的。 If you're not set on the idea that the DB needs to be on the phone, you can just make service calls via ajax to a server and access the db that way. 如果您不希望数据库在电话上,那么您可以通过ajax向服务器进行服务调用,然后以这种方式访问​​数据库。 I recently did a blog post exposing a db via a WCF Data service and consuming it on the phone. 我最近写了一篇博客文章,该文章通过WCF数据服务公开了数据库,并在电话中使用了它。 It doesn't cover calling it via ajax but should help get you started. 它不涉及通过ajax调用它,但应该可以帮助您入门。

http://www.ritzcovan.com/2012/02/building-a-simple-windows-phone-apppart-4/ http://www.ritzcovan.com/2012/02/building-a-simple-windows-phone-apppart-4/

如果要在WP7数据库中存储数据,请使用PhoneGap存储API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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