title: Having trouble inserting data to mysql datetimepicker
body: <p>How do you insert data into the database using <code>datetimepicker</code> in <code>VB.NET</code>? I tried to convert it using:
  <code>Format(name_of_the_datetimepicker.Value, "yyyy-MM-dd")</code> in my <code>SQL</code> statement but I don't know where did I go wrong.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    Imports MySql.Data.MySqlClient
      Public Class frmMain
      Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles       MyBase.Load
  
      If Not conn Is Nothing Then
          conn.Close()
      End If
  
      conn = New MySqlConnection("Data Source=" &amp; Server &amp; ";user id=" &amp; UserName &amp; ";password=" &amp; PassWord &amp; ";database=" &amp; DatabaseName &amp; ";")
  
      Try
          conn.Open()
      Catch ex As Exception
          MsgBox(ex.Message)
      End Try
  
  
      End Sub
  
      Private Sub btn_save_Click(sender As Object, e As EventArgs) Handles btn_save.Click
      Dim cmdSave As MySqlCommand
      Dim sql As String
      sql = "INSERT INTO (rental_date, inventory_id, customer_id, return_date, staff_id) VALUES ('" &amp; Format(dt_picker_rental_date.Value, "yyyy-MM-dd") &amp; "', '" &amp; txt_inventory_id.Text &amp; "', '" &amp; txt_customer_id.Text &amp; "', '" &amp; Format(dt_picker_return_date.Value, "yyyy-MM-dd") &amp; "', '" &amp; txt_staff_id.Text &amp; "')"
  
  
     Try
          cmdSave = New MySqlCommand(sql, conn)
          cmdSave.ExecuteNonQuery()
  
          MsgBox("Success!")
      Catch ex As Exception
          MsgBox(ex.Message)
      End Try
      End Sub
  </code></pre>