Connectiong to Mysql Database

Davide Fioravanzo 1 Reputation point
2020-11-09T19:35:04.44+00:00

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 ! ");
        }
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,631 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.