title: MySQL connection with C# through PHPMyAdmin created database
body: <p>We are sitting with a problem regarding MySQL database insertion.
  We have installed .NET connector and added MySql.Data.dll, MySql.Web.dll, MySql.Entity.dll to the /bin. As displayed in the code below, we are also using the right namespace. 
  However, when we try and insert data through the website, nothing gets inserted.
  The details for the database connection is provided from the webhotel.
  Domain location: <a href="http://testing.cce-solutions.dk/testBooking/is/interested/" rel="nofollow">http://testing.cce-solutions.dk/testBooking/is/interested/</a></p>
  
  <p>C# code:</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
  {
      MySql.Data.MySqlClient.MySqlConnection connection;
      string server = "db.cce-solutions.dk";
      string database = "web626445";
      string uid = "******";
      string password = "******";
      string connectionString;
      connectionString = "SERVER=" + server + ";" + "DATABASE=" +
      database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
      connection = new MySqlConnection(connectionString);
      try
      {
          connection.ConnectionString = connectionString;
          connection.Open();
          MySqlCommand cmd = new MySqlCommand("insert into  web626445 (yourName,YourEmail,YourPhone,Category,Description) values(@Name,@Email,@Telephone,@Category,@Description)", connection);
          cmd.Parameters.AddWithValue("@Name", YourName.Text);
          cmd.Parameters.AddWithValue("@Email", YourEmail.Text);
          cmd.Parameters.AddWithValue("@Telephone", YourPhone.Text);
          cmd.Parameters.AddWithValue("@Category", Category.SelectedItem.Value);
          cmd.Parameters.AddWithValue("@Description", Description.Text);
          cmd.ExecuteNonQuery();
      }
      catch (Exception ex)
      {
          DisplayMessage.Text = "Error occured. Please try again later.";
      }
      connection.Close();
      }}
  </code></pre>
  
  <p><strong>EDIT:</strong> 
  <strong><em>Firstly, thanks for all the answers!</em></strong> So we have implemented Rahul and ActiveHigh's answers and updated the code. Furthermore, we have added a way to check if the connection is a success or not. Now when we try to insert data we get the error message. The test location is still the same.
  Here is an image of the table in the database: <a href="https://www.dropbox.com/s/g2c70ty9qb1h7bw/ScreenshotDatabase.png" rel="nofollow">https://www.dropbox.com/s/g2c70ty9qb1h7bw/ScreenshotDatabase.png</a>
  Anyone have any idea what is going wrong or an idea how to debug it?</p>
  
  <pre><code>protected void Button1_Click(object sender, EventArgs e)
  {
      MySql.Data.MySqlClient.MySqlConnection connection;
      string server = "db.cce-solutions.dk";
      string database = "web626445";
      string uid = "******";
      string password = "******";
      string connectionString;
      connectionString = "SERVER=" + server + ";" + "DATABASE=" +
      database + ";" + "UID=" + uid + ";" + "PASSWORD=" + password + ";";
  
  
      connection = new MySqlConnection(connectionString);
  
      try
      {
          connection.Open();
          if (connection.State == ConnectionState.Open)
          {
              DisplayMessage.Text = "Data entered succesfully.";
              MySqlCommand cmd = new MySqlCommand("insert into  Booking (yourName,YourEmail,YourPhone,Category,Date,Description) values(@Name,@Email,@Telephone,@Category,@Date,@Description)", connection);
              cmd.Parameters.AddWithValue("@Name", YourName.Text);
              cmd.Parameters.AddWithValue("@Email", YourEmail.Text);
              cmd.Parameters.AddWithValue("@Telephone", YourPhone.Text);
              cmd.Parameters.AddWithValue("@Category", Category.SelectedItem.Value);
              cmd.Parameters.AddWithValue("@Date", "test");
              cmd.Parameters.AddWithValue("@Description", Description.Text);
              cmd.ExecuteNonQuery();
          }
          else
          {
              DisplayMessage.Text = "Database connection failed.";
          }
  
  
      }
      catch (Exception ex)
      {
          DisplayMessage.Text = "Error occured. Please try again later.";
      }
  
      connection.Close();
  </code></pre>