Connection must be valid and open VB.net error using vb.net
<p>This is my code for read data from EXCEL file using <code>ODBC driver</code> and write in <code>MySql</code> Database.</p>

<pre><code>Public Class WebForm3
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim MySqlCmd = New SqlCommand()

        ' Dim dialog As New System.Windows.Forms.OpenFileDialog()
        'Dim dialog As New OpenFileDialog()
        'dialog.Filter = "Excel files |*.xls;*.xlsx"
        'dialog.InitialDirectory = "C:\"
        'dialog.Title = "Select file for import"
        'If dialog.ShowDialog() = DialogResult.OK Then
        Try
            Dim dt As DataTable
            Dim buff0 As String
            Dim buff1 As String
            Dim buff2 As String

            dt = ImportExceltoDatatable("C:\\Book1.xls")

            For i = 0 To dt.Rows.Count - 1
                buff0 = dt.Rows(i)(0)
                buff1 = dt.Rows(i)(1)
                buff2 = dt.Rows(i)(2)

                Dim connStr As String = "server=localhost;user=root;database=ajaxsamples;port=3306;password=innoera;"
                Dim connMysql As MySqlConnection = New MySqlConnection(connStr)
                Dim sql As String = "INSERT INTO ajaxsamples.customers  VALUES('" &amp; buff0 &amp; "','" &amp; buff1 &amp; "','" &amp; buff2 &amp; "')"
                Dim cmd As MySqlCommand = New MySqlCommand(sql, connMysql)
                cmd.ExecuteNonQuery()
                cmd.Dispose()
                connMysql.Close()
            Next
        Catch ex As Exception
            MsgBox(Err.Description, MsgBoxStyle.Critical)
        End Try

        'End If
    End Sub


    Public Shared Function ImportExceltoDatatable(filepath As String) As DataTable
        ' string sqlquery= "Select * From [SheetName$] Where YourCondition";
        Dim dt As New DataTable
        Try
            Dim ds As New DataSet()
            Dim constring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" &amp; filepath &amp; ";Extended Properties=""Excel 12.0;HDR=YES;"""
            Dim con As New OleDbConnection(constring &amp; "")

            con.Open()
            Dim myTableName = con.GetSchema("Tables").Rows(0)("TABLE_NAME")
            Dim sqlquery As String = String.Format("SELECT * FROM [{0}]", myTableName)
            'Dim myTableName = con.GetSchema("Tables").Rows(0)("TABLE_NAME")
            'Dim sqlquery As String = String.Format("SELECT * FROM Sheet1$") ' "Select * From " &amp; myTableName

            Dim da As New OleDbDataAdapter(sqlquery, con)
            da.Fill(ds)

            dt = ds.Tables(0)
            Return dt
        Catch ex As Exception
            MsgBox(Err.Description, MsgBoxStyle.Critical)
            Return dt
        End Try
    End Function

End Class
</code></pre>

<p>I got this error, </p>

<blockquote>
  <p>"Connection must be valid and open "</p>
</blockquote>

<p>whats wrong in code? I am newbie for VB. Any help would be appreciated. </p>