0

I have written a simple database driven app in C# which uses a 2 table MySQL database. This is all a learning curve for me (except c#, which I am now comfortable with)

The app is small, has a couple of datagridviews, uses a few sql select/inserts statments to populate the datagridviews and also update records.

I want to port this app to Android. All of the internet sources I can find recommend a middle php sript which accepts http requests in order to fetch the data from MySQL and then return the results back to the android device where it is parsed with JSON etc etc.

This method is a little out of my reach since I dont have php experience, all of my attempts to implement the php layer have failed, speciially the android app was not receiving any data back, I'm assuming I messed up somewhere inside the php file.

Is there an easier (more noobproof) way to interact with the MySQL database from within android which doesnt require the need for php + JSON? Any ideas are appreciated, thank you in advance.

brux
  • 3,197
  • 10
  • 44
  • 78

4 Answers4

1

If you are comfortable with C#, why not use ASP.Net MVC for the middle man?

MVC is especially easy to deal with JSON, and you actually only need to create those "controllers" (as models should already be there from your existing app, and JSON don't need the View to display).

xandy
  • 27,357
  • 8
  • 59
  • 64
  • Ok this sounds interesting, i dont suppose you could provide me with a few more details how this might be done using visual web devloper express (im assuming). just a few pointers should get mer started, thanks – brux Nov 20 '10 at 15:00
  • You should start reading the document/tutorials in http://asp.net site. And in the controller, you need the JsonResult, you can google this and tons of examples there. – xandy Nov 20 '10 at 15:33
1

If your mobile application have to access a database over the network you should indeed build a web service fronted to the database.

By putting a web access layer on top of the database you can expose the required queries in an abstracted, secure and convenient manner.

Though this sort of web service architecture can be implemented with PHP + JSON other technologies can be used as well. If you feel more comfortable with C# you can use it to build the web service instead. By doing so you may even be able to reuse some of the code from your existing application.

Alex Jasmin
  • 39,094
  • 7
  • 77
  • 67
1

You can create a Web Service with C# that handles the data retrieval from the database; no need to go with PHP. Try create one with WCF API (check this question in order to create one). In order to create an Android client that consumes JSON on Android check this link.

Community
  • 1
  • 1
jmpcm
  • 1,814
  • 2
  • 19
  • 27
0

Actually, it would be better to take php in middle of android & mysql, due to the security concern and by the way this is the most easiest & comfortable method. here is link link. I hope you like it.

user609239
  • 3,356
  • 5
  • 25
  • 26