System.ArgumentException:不支持关键字" pwd"

时间:2016-09-26 10:32:02

标签: ios mysql unity3d

我正在开发一个需要MySQL连接的统一项目。

我的连接在Unity和Android版本中运行良好,但是当我将整个项目构建到iOS平台时,我遇到了一个错误(我通过一个记者插件对其进行了本地化)

首先例外:

System.ArgumentException: Keyword not supported. Parameter name: pwd at MySql.Data.MSqlClient.MySqlConnectionStringBuilder.ValidateKeyword (System.String keyword) [0x000000] in <filename unknown>:0

后来出现错误:

NullReferenceException: A null value was found where an object instance was required.
HandlerMySQL.Conectar ()

代码如下

using System.Collections.Generic;
using System.Security.Cryptography;
using MySql.Data;
using MySql.Data.MySqlClient;

public class HandlerMySQL{

    public string host, database, user, password;
    public bool pooling = true;

    private string connectionString;
    private static MySqlConnection con = null;
    private MySqlCommand cmd = null;
    private MySqlDataReader rdr = null;


    private MD5 _md5Hash;
    public HandlerMySQL(string h,string db, string u, string pw)
    {
        host = h;
        database = db;
        user = u;
        password = pw;
    }
    public void Conectar()
    {

        connectionString = "Server=" + host + ";Database=" + database + ";Uid=" + user + ";Pwd=" + password + ";Pooling=";


        if (pooling)
        {
            connectionString += "true;";
        }
        else
        {
            connectionString += "false;";
        }
        try
        {
            con = new MySqlConnection(connectionString);
            con.Open();
            Debug.Log("MySQL State: " + con.State);

        }
        catch(Exception e)
        {
            Debug.Log(e);
            Debug.Log("MySQL State: " + con.State);
        }
    }

    void OnApplicationQuit()
    {
        if (con != null)
        {
            if (con.State.ToString() != "Close")
            {
                con.Close();
                Debug.Log("MySQL Connection closed");
            }
            con.Dispose();
        }
    }


    public bool GetIsConnected()
    {
        if (con.State.ToString() == "Open")
        {
            return true;
        }
        else
        {
            return false;
        }        
    }

    public bool CreateData(string dnow, string dstart,int dend)
    {
        DataMySql data = new DataMySql(dnow, dstart, dend);
        if (DataToolsMySql.Agregar(data, con) > 0)
        {
            Debug.Log("Se agrego correctamente");
            return true;
        }
        else
        {
            Debug.Log("ERROR!!! No se agrego");
            return false;
        }
    }
}

0 个答案:

没有答案