title: How to connect VB.Net to Excel as Database Connection?
body: <p>I need a database connection using microsoft excel but i don't know what codes i should<br>
  use. I can only do a connection between access and VB but in excel I can't</p>
  
  <p>I copied this in the net but it doesn't work on me</p>
  
  <pre><code>Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  
      Dim MyConnection As System.Data.OleDb.OleDbConnection
      Dim DtSet As System.Data.DataSet
      Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
      'Fill the [Excel file fullpath] with specific value
      MyConnection = New System.Data.OleDb.OleDbConnection _
      ("provider=Microsoft.ACE.OLEDB.12.0;Data Source= E:\DATABASE\VBtoExcel\VBtoExcel\bin\DataBaseExcel.xlsx; Extended Properties=Excel 12.0;")
      MyCommand = New System.Data.OleDb.OleDbDataAdapter _
          ("select * from [Sheet1]", MyConnection)
      MyCommand.TableMappings.Add("Table", "TestTable")
      DtSet = New System.Data.DataSet
      MyCommand.Fill(DtSet)
      DataGridView1.DataSource = DtSet.Tables(0)
      MyConnection.Close()
  
  End Sub
  </code></pre>