0

Im checking a connection for an online database for a Xamarin.android but this erroer keeps on appearing..im planning to connect it to a rasp pi database for my research project..pls help

using Android.App;
using Android.OS;
using Android.Widget;
using MySql.Data.MySqlClient;
using System;
using System.Data;

namespace sqq
{
[Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]
public class MainActivity : Activity
{
    private EditText urs, pss;
    private Button sin;
    private TextView suc;
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        SetContentView(Resource.Layout.activity_main);


        sin = FindViewById<Button>(Resource.Id.button1);
        urs = FindViewById<EditText>(Resource.Id.textView1);
        pss = FindViewById<EditText>(Resource.Id.textView2);
        suc = FindViewById<TextView>(Resource.Id.textView3);

        sin.Click += Sin_Click;

    }
    private void Sin_Click(object sender, EventArgs e)
    {
        MySqlConnection con = new MySqlConnection("Server=db4free.net; Port=3306;       Database=rolandvill; User Id=roland11; Password=roland123;charset=utf8");

        try
        {

            if (con.State == ConnectionState.Closed)
            {

                con.Open();
                suc.Text = "Success";

            }
        }
        catch (MySqlException ex)
        {
            suc.Text = ex.ToString();

        }
        finally
        {
            con.Close();
        }

    }
}
}

ive been trying all the solution ive seen here but none of it works.

here's where error happens enter image description here

heres the code for my activity_main.axml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
    <EditText
    android:text="UserName"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minWidth="25px"
    android:minHeight="25px"
    android:id="@+id/textView1" />
<EditText
    android:text="Password"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/textView1"
    android:id="@+id/textView2" />
<Button
    android:text="Button"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/textView2"
    android:id="@+id/button1" />
<TextView
    android:text="Medium Text"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/button1"
    android:id="@+id/textView3" />

 </RelativeLayout>
  • Which line does the error occur ? Could you share the code for could you share the code for `SetContentView(Resource.Layout.activity_main)` – Anu Viswan Feb 23 '20 at 12:22
  • ive updated the post – Roland Peralta Villaruz Feb 23 '20 at 12:54
  • 1
    I think the connection string is wrong which is getting an obtuse error message. Can you verify the connection string? – jdweng Feb 23 '20 at 13:07
  • @jdweng its the standard connection string – Roland Peralta Villaruz Feb 24 '20 at 05:55
  • The connection string is not working. Could be a license issue, the port is blocked, or a virus is attacking port 3306. – jdweng Feb 24 '20 at 07:03
  • I just got your comment today saying : "@jdweng its the standard connection string". The connection string could still be wrong. There could also be something wrong with the MySqlClient library. Open solution explorer and right click reference for theMySqlClient libary. Then check were it is located. The library may need updating or need to be reinstalled. – jdweng Mar 04 '20 at 12:16

1 Answers1

1

Referring to earlier post here and mysql bug report

Adding 'OldGuids=True;' into the connection string works:

MySqlConnection con = new MySqlConnection("Server=db4free.net; Port=3306;       Database=rolandvill; User Id=roland11; Password=roland123;OldGuids=True;charset=utf8");

Also, as @Bradley Grainger said, by adding OldGuids=true, you should be aware that any BINARY(16) column will be returned as a Guid rather than byte[].

Lia
  • 523
  • 2
  • 9