Muhammad Nadeem

Muhammad Nadeem

  • NA
  • 548
  • 65.8k

xamarin form app connect to shared server cpanel hosting

Apr 28 2019 2:03 AM
Hi,
 
I have xamarin forms app and I want to connect my app to my shared server mysql database. I want to connect my app with mysql database that is on real server here is the code to do this.
  1. MySqlConnectionStringBuilder sb = new MySqlConnectionStringBuilder();  
  2. sb.Server = "my ip addres or domain name";  
  3. sb.Port = 3306;  
  4. sb.UserID = "myuserid";  
  5. sb.Password = "mypassword";  
  6. sb.Database = "mydbname";  
  7. sb.CharacterSet = "utf8";  
  8. try  
  9. {  
  10. MySqlConnection con = new MySqlConnection(sb.ToString());  
  11. if (con.State == ConnectionState.Closed)  
  12. {  
  13. con.Open(); // when connection is going to open then this happen "The type initializer for MySql.Data.MySqlClient.Replication.ReplicationManager threw an exception."  
  14. DisplayAlert("alert""successfully connected""ok");  
  15. }  
  16. }  
  17. catch (Exception ex)  
  18. {  
  19. DisplayAlert("Error", ex.Message, "ok");  
  20. }  
I used Xamarin.MySql.Data Plugin in my xamarin form app.
 
https://www.nuget.org/packages/Xamarin.MySql.Data/
 
Please help me I want to online my xamarin form app/connect to my domain cpenal hosting.

Answers (1)