Connectiong to Mysql Database
Davide Fioravanzo
1
Reputation point
How can I connect my Sql Database with my application?
Actually I use this code.
SqlConnection cnn;
string server = "localhost";
string database = "entrata";
string uid = "";
string password = ""; //im using mampp
string connectionString;
connectionString = "SERVER=" + server + ";" + "DATABASE=" + database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
MySqlConnection connection = new MySqlConnection(connectionString);
cnn = new SqlConnection(connectionString);
try
{
cnn.Open();
Console.WriteLine("Connection Open ! ");
cnn.Close();
}
catch (Exception ex)
{
Console.WriteLine("Can not open connection ! ");
}
Sign in to answer