title: How to connect to mysql with C# (simple program)
body: <p>I am a beginner in C # and I intend to create a simple program to check the connection to the mysql server (in this case I am using xampp, so the connection is local).
  The problem is that the connection to the mysql server does not work, so the "Can not open connection!" box pops up. I appreciate all the explanations. thank you :)</p>
  
  <pre><code>using System;
  using System.Data;
  using System.Data.SqlClient;
  using System.Windows.Forms;
  using MySql.Data.MySqlClient;
  
  namespace WindowsFormsApp1
  {
  public partial class Form1 : Form
  {
  
      public Form1()
      {
          InitializeComponent();
      }
  
      private void btnSend_Click(object sender, EventArgs e)
      {
          SqlConnection cnn;
          string server = "localhost";
          string database = "test";
          string uid = "root";
          string password = "";   //im using xampp
          string connectionString;
          connectionString = "SERVER=" + server + ";" + "DATABASE=" +
          database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
          MySqlConnection connection = new MySqlConnection(connectionString);
  
          cnn = new SqlConnection(connectionString);
          try
          {
              cnn.Open();
              MessageBox.Show("Connection Open ! ");
              cnn.Close();
          }
          catch (Exception ex)
          {
              MessageBox.Show("Can not open connection ! ");
          }
      }
  
      private void button1_Click(object sender, EventArgs e)
      {
          this.Close();
      }
  }
  </code></pre>
  
  <p>}</p>