VB.NET Excel file not connecting with virtual datagridview
<p>I am trying to write a module in my VB.NET application, but it isn't working properly.
I am trying to create a datagridview, and load an excel file into it. However, the Excel isn't loading in it.</p>

<p>Code below</p>

<pre><code>Imports Microsoft.Office
Imports Microsoft.Office.Interop
Imports System.Data.OleDb
Imports System.Net.Mail

Module m_IslsHpPtSplit
Dim UploadFilePath As String
Dim UploadFileName As String

Dim dgv1 As DataGridView
Dim dgv2 As DataGridView

Public Sub LoadFile()
    dgv1 = New DataGridView
    dgv2 = New DataGridView
    Try
        Dim filedialog As OpenFileDialog = New OpenFileDialog()
        Dim path As String
        filedialog.Title = "Select file"
        filedialog.InitialDirectory = "Desktop"
        filedialog.RestoreDirectory = True
        If filedialog.ShowDialog() = Windows.Forms.DialogResult.OK Then
            path = filedialog.FileName
        Else
            path = Nothing
        End If
        UploadFilePath = filedialog.FileName
        UploadFileName = System.IO.Path.GetFileName(filedialog.FileName)
        Dim dtSheet1 As New DataTable

        If Not path = Nothing Then
            Using cn As New System.Data.OleDb.OleDbConnection
                Dim Builder As New OleDbConnectionStringBuilder With _
                    { _
                        .DataSource = path, _
                        .Provider = "Microsoft.ACE.OLEDB.12.0" _
                    }
                Builder.Add("Extended Properties", "Excel 12.0; IMEX=1;HDR=Yes;")
                cn.ConnectionString = Builder.ConnectionString

                cn.Open()

                Using cmd As OleDbCommand = New OleDbCommand With {.Connection = cn}
                    cmd.CommandText = "SELECT * FROM [FNAC$]"
                    Dim dr As System.Data.IDataReader = cmd.ExecuteReader

                    dtSheet1.Load(dr)
                    dgv1.DataSource = dtSheet1
                End Using
            End Using
            MessageBox.Show(dgv1.RowCount)
            MessageBox.Show("Done")
        End If
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
    SplitFile()
End Sub 'LoadFile
</code></pre>

<p>After that, I need to perform some calculations etc, but the line </p>

<pre><code>MessageBox.Show(dgv1.RowCount)
</code></pre>

<p>actually returns 0. The excel file has 316 lines in it.
How can I get the data to stick to the new dgv?</p>