- Home /
cannot connect unity to sql server 2012
Hello,
I am now to unity and i wan to make sql server 2012 connection. So i installed the sql server 2012 and made a successful connection using C# in a windows form application.
So I made some researches to make it in unity, and i got the following Code:
// Connect to database
public void openSqlConnection() {
Debug.Log("Connecting to database...");
string connectionString = "Server=127.0.0.1;" +
"Port=1433;" +
"Database=mydatabase;" +
"User ID=userId;" +
"Password=mypass;" +
"Pooling=False;";
dbConnection = new MySqlConnection(connectionstring);
dbConnection.Open();
Debug.Log("Connected to database.");
}
When i call this function to open the connection i get this error :
Exception: Exception of type 'System.Exception' was thrown.
MySql.Data.MySqlClient.NativeDriver.Open ()
Rethrow as MySqlException: Unable to connect to any of the specified MySQL hosts.
MySql.Data.MySqlClient.NativeDriver.Open ()
MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings)
The problem is that the connection using a windows form application is successful but using c# in unity isn't.
So help me please!! thanks!
Thanks i figured it out!! I used dbConnection = new SqlConnection(connectionstring);
ins$$anonymous$$d of
dbConnection = new $$anonymous$$ySqlConnection(connectionstring);
Your answer
Follow this Question
Related Questions
Sql Server Compact 4.0 error 2 Answers
Unity and database 1 Answer
A node in a childnode? 1 Answer
How to integrate SQL database in game? 1 Answer
SqlConnection Error con.Open() 0 Answers