title: Connection string to connect to MySql database?
body: <p>I am trying to connect MySql database to my forms. I got the connection string by right clicking on my database connection and going to properties.</p>
  
  <pre><code>connection.ConnectionString = "server=localhost;user id=root;database=island_dealership;"+
         "persistsecurityinfo=True;allowuservariables=True";
  </code></pre>
  
  <p>Below is image of an error and complete code.</p>
  
  <p><a href="https://i.stack.imgur.com/XuK4r.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XuK4r.jpg" alt="enter image description here"></a></p>
  
  <p>car.cs class: here I'm trying to connect to the database. </p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.ComponentModel;
  using System.Data;
  using System.Drawing;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows.Forms;
  using MySql.Data.MySqlClient;
  
  namespace DatabaseProject
  {
      public partial class Car : Form
      {
          MySqlConnection connection = new MySqlConnection();
          MySqlConnection cmd;
          public Car()
          {
              InitializeComponent();
          }
  
          private void Form1_Load(object sender, EventArgs e)
          {
              try
              {
                  connection.ConnectionString = "server=localhost;user id=root;database=island_dealership;persistsecurityinfo=True;allowuservariables=True";//Connection String....
                  connection.Open();
                  MessageBox.Show("Connected to MySql database");
              }
              catch(Exception e1)
              {
                  MessageBox.Show("Connection failed Due to " + e1.ToString());
              }
  
          }
  
          private void submitCar_Click(object sender, EventArgs e)
          {
  
          }
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/pbffK.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pbffK.jpg" alt="enter image description here"></a></p>