Connect a database and a phone app

Soldato
Joined
22 Apr 2009
Posts
3,716
Location
North-West
I currently have a Windows Phone 7 App that reads RSS links and displays them in an appropriate format to the user.

Sepperate to that i have a database with a table that consists of 4 fields. I want to be able to display that information using the RSS feed app.

Does anyone know how i can set the database up to work that way?

The database is an SQL database made in visual studios in an empty ASP website.
 
One solution would be to set up a web service that provides the information from the database in a format that the app can understand, e.g JSON or XML.

A few apps I wrote for someone needed information from a data store somewhere, and it was provided in a JSON format using a web service.
 
Even if you could access a remote DB directly it would be unrecommended. As stated before the way to do it would be a web service spitting out either XML or JSON and the mobile app picking up this data and parsing it. Easily done within a MySQL/php environment and I imagine it can't be that difficult within a SQL server/.net environment.
 
Do you have a specific problem with the tutorial visibleman linked to? It should do exactly what you want.

And yes, apps can happy read from databases themselves - http://msdn.microsoft.com/en-us/library/hh202860(v=vs.92).aspx

There was no problem with visibleman's link, I am just looking at all the possibilities. I wanted to incorporate different forms of data subscription. I already used an RSS feed in a different section so wanted to see other options :)
 
if you're new to programming, this isn't going to be easy im afraid.

(very basically) you would need to have the following structure in place:

Windows Phone App

[which links to]

A Web Service - This is usually a secure online application but built purely to serve and accept data between another app (i.e. your windows phone app) and the database. The web service will have specific methods programmed into it which your App can utilize to retrieve and manipulate data in the database remotley.

Sorry if you're already aware of this.
[which in turn links to]

The Database (i.e. an sql server or mysql database)
 
You want to be using SQLite, its a very simple command line DB and it works on all major smartphone platforms.

The benefit is that you can easily migrate your app to another platform as the database is multiplatform. You can run it on an iPhone, android or windows 7 phone without changing anything in the database. The DB is local to the device so your not relying on a service.
 
You want to be using SQLite, its a very simple command line DB and it works on all major smartphone platforms.

The benefit is that you can easily migrate your app to another platform as the database is multiplatform. You can run it on an iPhone, android or windows 7 phone without changing anything in the database. The DB is local to the device so your not relying on a service.

Any Tutorials on that?
 
I would have thought only using a local SQLite db is fine as long as it's static data you are referencing but if the data is changing in real time you either need a web service to send the live data to the device or a web service to update the locally stored SQLite db on the device every so often or when connection is possible.
 
Sorry to hijack this!

I'll be attempting something similar soon and want to go down the route of 'copy data from my SQL Server to a local SQLite database so the app will work in situations without and internet connection'

I've had a look at web services, and lots of Google results seem to point to something called Master Data Services.

Do I need to use MDS in order to create a Web Service, or is MDS one of the ways to create a Web Service?

How would you accomplish what I'm trying to do?

Thanks :D
 
For SQLite tutorials there's some good stuff on lynda.com but it's not free. There are tutorials on youtube but i'm not sure how good they are.

Sorry to hijack this!

I'll be attempting something similar soon and want to go down the route of 'copy data from my SQL Server to a local SQLite database so the app will work in situations without and internet connection'

I've had a look at web services, and lots of Google results seem to point to something called Master Data Services.

Do I need to use MDS in order to create a Web Service, or is MDS one of the ways to create a Web Service?

How would you accomplish what I'm trying to do?

Thanks

It sounds like you want to pull data out of your SQL Server db and create a JSON object with all the data. Then pull the JSON data from the web service and store it as the correct objects, then once you've got your data in your application, you can then store it into a local db.

I say JSON because i thing its a better approach than using XML.



Where is your SQL Server db getting its data from? if that's is getting data from another web service then you could just cut that database out of the situation and connect your app upto the webservice and then store that data in SQLite.

If it isn't, can't you just drop the SQL server db and just use a local SQLite db.

But it depends what your app is doing and how is uses data.
 
For SQLite tutorials there's some good stuff on lynda.com but it's not free. There are tutorials on youtube but i'm not sure how good they are.



It sounds like you want to pull data out of your SQL Server db and create a JSON object with all the data. Then pull the JSON data from the web service and store it as the correct objects, then once you've got your data in your application, you can then store it into a local db.

I say JSON because i thing its a better approach than using XML.



Where is your SQL Server db getting its data from? if that's is getting data from another web service then you could just cut that database out of the situation and connect your app upto the webservice and then store that data in SQLite.

If it isn't, can't you just drop the SQL server db and just use a local SQLite db.

But it depends what your app is doing and how is uses data.

I've actually sorted this bit out now I think - I've got a web service polling the database for data based on a reference I pass as a url parameter. I am formatting the output as a JSON string.

A question I do have is about security...I'm happy that my database is safe as I'm using one hardcoded SELECT query and the user I'm using has read only privileges, however anyone at the moment could browse to the URL of the webservice and potentially access the data. How would I prevent this? I had an idea of using a random string as a kind of 'token' and checking for this in the web service before a result is returned?

Is this the right thing to do?
 
Yes using a token or password will work.

when your passing your parameters, you can add another one for a password/token and before you execute the script that connects to the DB you can do a token check to see if the token is in the db, if it returns true then carry on.
 
Yes using a token or password will work.

when your passing your parameters, you can add another one for a password/token and before you execute the script that connects to the DB you can do a token check to see if the token is in the db, if it returns true then carry on.

Just make sure you are calling the web service via https rather than http though as it'd be easy to sniff the token value.
 
Back
Top Bottom