简体   繁体   中英

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. The app needs to:

  • Allow the user to login by connecting to an sql server database (stored locally for the purpose of this project)
  • If login successful, return a list of products associated with the user (ie in product table where 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)
  • 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

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.

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). 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. I dont think that its possible to make calls directly from Javascript to LinqToSql on the phone. 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. I recently did a blog post exposing a db via a WCF Data service and consuming it on the phone. It doesn't cover calling it via ajax but should help get you started.

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

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

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