I am getting the above error when I execute the code -
MySqlConnection mysqlConn=new MySqlConnection(\"server=127.0.0.1;uid=pankaj;port=3306;pwd=master;datab
Just ran into the same problem. Installing the .NET framework on the target machine solved the problem.
Better yet, make sure all required dependencies are present in the machine where the code will be running.
use SqlConnectionStringBuilder
to simplify the connection
System.Data.SqlClient.SqlConnectionStringBuilder builder = new System.Data.SqlClient.SqlConnectionStringBuilder();
builder["Initial Catalog"] = "Server";
builder["Data Source"] = "db";
builder["integrated Security"] = true;
string connexionString = builder.ConnectionString;
SqlConnection connexion = new SqlConnection(connexionString);
try { connexion.Open(); return true; }
catch { return false; }
I was having the exact same error.
Here's what you need to do:
If you are using MAMP, close your server. Then click on the preferences button when you open up MAMP again (before restarting your server of course).
Then you will need to click on the ports tab, and click the button "Set Web and MySQL Ports to 80 & 3306".