I want to building an android app by Xamarin, C# language. This app can get or insert data to MySQL, this SQL hosted on another PC
So, Where I can get information and tutorial for this?
Thank you!
Basically if your MySQL database is in another computer, you need to communicate to it over web, I would suggest you use API, in computer with database make API Application.
https://learn.microsoft.com/en-us/aspnet/core/web-api/?view=aspnetcore-5.0
There is microsoft documentation for it.
Create endpoints for specific actions, and then communicate with them from your Xamarin App, here's the documentation: https://learn.microsoft.com/en-us/aspnet/web-api/overview/advanced/calling-a-web-api-from-a-net-client
Create API service on computer with database
Communicate from your application to API (then API communicates with database, and sends back results to your Xamarin App)
I personally like RESTful principles for API's. documentation: https://restfulapi.net/
You should also consider adding authentication to API, so that only apps you want, can GET/INSERT data to your database
to get data from mysql in any app you need to API:
i using ASP webservice to get data from mysql
then in Xamarin.Android APP in refrence folder click right and add web refrence .
watch this video :
https://www.youtube.com/watch?v=XTZ8pbWAVW4&list=PLF8OvnCBlEY3qYheTm4gnaoWwBuBf2TUj&index=46
Related
I'm working on a project and I need to connect to MS Access Database. The problem is that I'm using a pretty new platform , I'm using Visual Studio 2015 Xamarin and I'm developing to android with c# (thought this platform).
I already have a project with this Database using aspx and i need to connect the android application to this Database .
I could not find any answer for it , probably cause it's new .
Thanks for helping.
The problem is not related only to Xamarin or MS Access.
Everytime you want to use the same database in different applications (in your case a website and mobile apps), it is better to create a new layer (WCF Service or REST API) in order to access the same database on the server. This is more flexible and would be the right thing in your case.
Without moving the architecture to the next Level, you will always have such problems when mixing old and new technologies together.
If you just want to finish this quickly for school and use the database only on the device, then there is no way to use the MS Access database with xamarin. I recommend using SQL lite for this and there are lots of examples for that:
https://developer.xamarin.com/recipes/android/data/databases/sqlite/
It not clear if the database is to run “local” on the android, or you just wishing to connect to some web service that holds the database?
If you needing a local database to run 100% stand-alone on the Android device, then Access is not supported. Your best bet for a local database would thus be SQLite.
Perhaps you don’t need nor want a local data store. In this case if the Access database is on the server, then you would be forced to write some kind of web service to “interact” with your Android software and the web server (this would not be a "general" interface to the database, but a set of web services that you expose on the web site - this assumes you thus have control and are able to write software and implement a web service on the web site. So in this case some kind of “direct” connection to the Access database is not possible.
You could again certainly DIRECTLY connect to a server based database like SQL server – but this would assume the web hosting allows external ODBC connections to the database (often they don’t allow this, but some do).
So not clear is if you need a local database running on the Android that can THEN connect to some web or server based system, or you simply want the android to connect via the internet to some database hosted on some server and the Android device does not have a local database at all.
Regardless of the location of MSAccess, you cannot "connect" to a non server database like Access. So the question remains as to "where" you want this database to be used, and ALSO if you need a local data store on the Android device or not.
I am developing an app for selling of products, but I am stuck up in a place where I am not understanding how to give notifications to android phone from database change(insert or update on that table) for new products availble and offers like discounts, schemes etc.
I followed androidhive.com and javapapers.com for the GCM push notifications concept and it is sort of clear:
PHP or C# or Java web service
MySQL or SQLServer Database
GCM
Android phone
The statement for my problem would be "App should receive push notifications for new products, and offers and discounts given by the person-in-charge for it"
My assumption for this problem is:The "offers and discounts" would be "inserted" to a table(tbl_products) in the database and same goes for new products, "inserted" into a table(tbl_offers) in the database.
As soon as that "insertion" is done, the web service (php and c#), which I don't know how it should know, but gets to know about the change and informs GCM, and GCM sends the notification to the respective users.
The logic behind this is not familiar to me. I would greatly appreciate it if someone would help me with the logic and point me in the right direction of the coding for Android and web service. Thank you in advance.
I have been there ,done that! The way you should to proceed is:-
Create your website backend, a web service connected to a database(You need to use and know SQL for this part). Define your database accordingly. PHP is the easiest way to get started. Look at the GCM backend tutorials on Google.
Create your mobile application which has google play services enabled to use GCM. Implement GCM in your android app following the tutorial at the Official Android Developer website. You need to create an XMPP or RESTful service to communicate with your server. Your server needs to support XMPP to communicate better with Google. HTTP(GET/POST/PUT) is a dirty alternative to get working when you do not have a VPS setup for languages like Java(Most hosting companies allow only PHP,HTML,JavaScript etc on shared hosting).Depending on your scale of operation you may have to rent a Virtual Private Server(VPS) for your web service.
Create a private backend application(can be web or a desktop application) to upload your offers and so on. Examples on www.androhive.info
Make sure you got steps 1,2,3 correct.
Test your mobile application.
The idea can be pictorially represented as :-
I'm pretty new in developing pc and mobile applications that need to work with the same database.
Maybe this isn't really a question but I would be happy to get some advice from you.
I have now a vs project written in C# with a Service-Based Database. I want to create a mobile app (can be only for android) and I want both the apps to use the same database.
What options do I have? Windows Azure isn't free and I can't spend any money on this so even a small trial (limitless) will work here.
I was thinking using Parse..
What do you recommend?
If I understand correctly I would suggest you create some backend service - web service or web api - that both application use which in turn uses the database.
This will allow you to re-use business logic across both applications, abstract the database away so that you can make database and logic changes without having to redeploy the applications and avoid the requirement to deploy database credentials with your applications (the backend service should employ some form of authentication)
A free-tier Azure mobile services can really help with the mobile device end but not necessarily on the PC (unless windows store app), but a free-tier Azure websites instance will happily host either web service or web api
I have a pre-existing desktop application that draws its information from a Microsoft SQL Server. The desktop application is written in C#/ASP/.NET.
I'd like to take this same data and present it in an iPhone application. What would be the best way to obtain and present the data?
I would recommend writing a web service that exposes the data and then interfacing with this from the iPhone across the network.
Calling web services and making HTTP calls is very easy on the iPhone.
Do you assume your iPhone application will have network access? If so I would go the webservice route as already mentioned. If it's a small database that you want available on the iPhone with out the need to access the internet to retrieve data you could look at converting the SQL Server database into a SQLite database and packaging it with your app.
I am trying to create an integrated project in which I can update MS-SQL's database value using J2ME's application.
But I need more resources/links that let me fully understand how to go about writing implementation for this.
These are the few question in which I've got in mind.
How do I update the data that I've got from J2ME into MSSQL 2005?
How do I retrieve and view the updated value from the database?
How do I send sms to the J2ME's application, as the other application of mine need to send an 'alert' to the j2me app.
Short of writing your own ODBC library for J2ME, I would suggest you look at writing a web service layer over your database which the J2ME application can communicate with over HTTP.