未处理的异常:System.FormatException:Guid应该包含32个数字,带有4个破折号(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxxx)

问题描述 投票:1回答:1

我正在检查Xamarin.android的在线数据库的连接,但此错误不断出现。.im计划将其连接到rasp pi数据库以供我的研究项目使用。.pls帮助

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,但是都没有用。

这里是发生错误的地方enter image description here

这里是我的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>
c# xamarin.android
1个回答
0
投票
参考earlier post heremysql bug report

[添加'OldGuids = True;'进入连接字符串的工作方式:

© www.soinside.com 2019 - 2024. All rights reserved.