Answer the question
In order to leave comments, you need to log in
How to connect to a hosting with a database from Android?
Greetings.
I am developing a mobile application on Xamarin.Forms, which provides a connection to a hosting with a database.
When testing the code on Windows UWP, no errors were found, the program connects to the database, sends a request and gets the correct result.
However, when testing the same when on Android (on a really connected phone), it is not possible to connect to the database.
I separately connected MySQL.Data to the Android project. Tell me
, please, what am I doing wrong.
code for connecting to the database:
string MyConString = "SERVER=tut ssilka.com;" +
"DATABASE=nameDB;" +
"UID=ID;" +
"Pwd=TutParol;";
var MyConnection = new MySqlConnection(MyConString);
try
{
MyConnection.Open();
label2.Text = "Connected";
}
catch(Exception e)
{
label2.Text = "No connection";
}
Answer the question
In order to leave comments, you need to log in
As it is correct to eat in the default constructor of the application. Create a new project and check the generate backend box.
Briefly, then.
1. The back connects to the database and prepares the data, giving only json, doing a bunch of tasks along the way
2. The service in your mobile application makes requests
3. ViewModel - provides data for display, contains commands for interaction, caches data so as not to pull it once again 2.
4. View simply draws the ViewModel, displays dialogs, progress bars and everything else related to the UI.
It is correct not to connect from Android to the database on the hosting.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question