Here is my code in Visual Studio connected to Unity3d:
public void SetupSQLConnection()
{
Debug.Log("Connection Function Started");
if (connection == null)
{
Debug.Log("If connection == null");
try
{
Debug.Log("Try block started");
string connectionString = "Server=localhost;" + "Database=therapygame;" + "UID=root;" + "Password=;";
Debug.Log("string set");
connection = new MySqlConnection(connectionString);
Debug.Log("new MySqlConnection");
connection.Open();
Debug.Log("connection");
}
catch (MySqlException ex)
{
Debug.LogError("MySQL Error: " + ex.ToString());
}
}
}
The Console strings get printed all the way to "string set", but then the rest do not print.
Here is the error in Unity:
KeyNotFoundException: The given key was not present in the dictionary. System.Collections.Generic.Dictionary`2[System.String,System.Object].get_Item (System.String key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150) MySql.Data.MySqlClient.MySqlConnectionStringBuilder.get_Database () MySql.Data.MySqlClient.MySqlConnection.set_ConnectionString (System.String value) MySql.Data.MySqlClient.MySqlConnection..ctor (System.String connectionString) (wrapper remoting-invoke-with-check) MySql.Data.MySqlClient.MySqlConnection:.ctor (string) mysql.SetupSQLConnection () (at Assets/mysql.cs:31) fire_rate.Start () (at Assets/fire_rate.cs:18)