Connect to MySql database through xamarin - mysql

I'm currently doing a iOS application for school to connect to school mysql database.
It should be able to connect to it through the tools on xamarin studio.
I tried a lot of different coding to connect the database, but was unable to do so.
Is there any tutorial or example code to let me learn on how to do it ?
Thanks for any help!

Do not connect directly to a database from a mobile app. Doing this requires exposing your database server directly to the web, which is a horrible security risk. The better approach is to use a web services layer to broker the interaction between your client and your server.
http://docs.xamarin.com/guides/cross-platform/application_fundamentals/web_services/

While people are right and the best way to connect to a database is to use a web service there are some times you want to connect directly and ways to make the connection more secure (ip restrictions on the mysql server).
Here is a plugin with code examples on how to do it:
https://components.xamarin.com/view/mysql-plugin
Be sure to pay attention to the first forum question on errors and how to resolve. You need to include a reference to system.data, I18N, I18N.West in your project and also make a call to the constructor for I18N somewhere in your code.
new I18N.West.CP1250();

Related

Accessing Mysql Database from a Machine to another machine using an application

So, I basically made a Windows Application using Visual Studio 2019, and used MySQL as my database to store records.
Now I want to publish that application and send it to a client or try to run it on a different machine, but i think since i have used the localhost as my database connection it wont be able to read or write data on my database from another machine.
So basically I want to know how can i host my mysql database on a machine and access that database from another machine using an application.
I am unable to find any sort of guide to do it online, if someone can guide me or give me a referrence from where I can get information and solve my issue.
You can expose your localhost to be accessed remotely, However, this is not ideal or advised. I will suggest you host your database on one of the virtual or cloud services and access it in your application.
Examples of services like https://remotemysql.com/ https://www.db4free.net/ which I advice you use for testing purpose only. You can create your database and they will give you the connection parameters to fill your connection string.
Let me know if is helpful.

How to Connect Xamarin Forms to MySQL database as backend of the app without webservice?

How to Connect Xamarin Forms to MySQL database as backend of the app without webservice?
i'm using a control panel website called myasp.net it offers a MySQL online database , and here's my phpMyAdmin i already set up all of the tables i needed, and i want to connect it to my xamarin forms application directly. is it possible?
I think your question also goes somewhat like this one I answered, and you are asking so many things with very few lines.
is it possible Xamarin.Forms Android and iOS with Sqlite syncing to MySql?
again, you need to create an API to reach there.
OR
if it is a huge learning curve for you right now, you can get a free azure account and create an Azure Function, as www.myasp.net offer MySQL get the connection credentials.
refer to this :
Azure Database for MySQL: Use Node.js to connect and query data

How do I connect a desktop app to an hosted database

I am developing a desktop app and I want to store data in hosted database like MySQL/MongoDB. I know one solution is using webservice to manipulate db. I am wondering is there a way to connect desktop app with hosted db directly.
I am using OpenShift I know I can use port-forward to do this. But it's unpractical to open port forward every time for every PC. So is a way simply like this:
mongoose.connect('mongodb://user:pass#host:port/db');
I tried this but I got 'connect refused' or 'connect not found' errors. OpenShift doesn't allow external access to database directly because security issues, right? Then how could I do it without port-forward?
Also I read some articles about SSH, is it possible to use SSH to access db directly when desktop app is launched?
Thanks for any suggestion.
I don't think OpenShift is going to be a good fit for what you are trying to do, unless you decide to build a service layer between your desktop app and the database. It sounds like you are looking for a Database As A Service. You mentioned both MongoDB and MySQL. MongoLab is a good MongoDB DBaaS option. For other databases like MySQL, PostgreSQL and several others you could look at Amazon RDS.

How to connect to a client server database in PhoneGap?

I have been searching this topic for a long time but I haven't found the answer I wanted. I want to connect to a MySQL database on a client-server and insert some info on a table using an app I made using PhoneGap. I found things like that but didn't seem to do what I want them to do: http://docs.phonegap.com/en/2.7.0/cordova_storage_storage.md.html#SQLTransaction
This documentation page doesn't make any sense to me.
Does anyone know how can I solve my problem? Thanks in advance.
You normally don't access database on your server dirrectly from the app in your phone.
The doc you saw about SQLTransaction is about writing data to the SQLite database that is inside your device, not to write to a remote database.
What is usually done to communicate with a remote database is we perform http requests to a web server (php, java, .net, ruby, perl or whatever you like) and that server will communicate with the database server.
If you really want to communicate with your mysql server from your phonegap app, you would have to include native mysql libraries in your project and write native code to communicate with the mysql server. And I don't think it woule work very well through a data connection...

Database is not connected to my website build on ASP.Net

I got stuck in deployement of my website built using ASP.Net, C# and using sql server 2008 database. The problem is that website is working perfectly fine on localhost but it is not connecting with database when I hosted it on web, I know that the problem is in Sql server database in giving permission or something but I don't know exactly because the connection and user which I have created is exactly the same as I used while development and as soon as I deployed it on web the part which is not using database is working fine that is login page but when I enter username and password in the interface and hit login it does not go into database and pull the data, I mean it does not connect to database at all.
My question is that does it matters in accessing database from localhost and from web, Though I am still using My local computer for Coding and using the company"s database through VPN. This is first time I am deploying the website on web and I need some help, I know my way of asking question might ambiguous but please try to understand and if you have some question than please ask don't just ignore.
Many thanks in advance.
Most frequent solutions:
Enable TCP/IP protocol for sql server instance.
Enable SQL Server Browser service.
Open firewall ports.
More information:
http://blog.sqlauthority.com/2009/05/21/sql-server-fix-error-provider-named-pipes-provider-error-40-could-not-open-a-connection-to-sql-server-microsoft-sql-server-error/