click event handle
of it and do the following codes for reading the excel file.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim con As OleDb.OleDbConnection Dim cmd As New OleDb.OleDbCommand Dim da As New OleDb.OleDbDataAdapter Dim dt As New DataTable Try With OpenFileDialog1 .Filter = "Excel files(*.xlsx)|*.xlsx|All files (*.*)|*.*" .FilterIndex = 1 .Title = "Import data from Excel file" End With If OpenFileDialog1.ShowDialog() = DialogResult.OK Then TextBox1.Text = OpenFileDialog1.FileName con = New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & TextBox1.Text & " ; " & "Extended Properties=Excel 8.0;") con.Open() With cmd .Connection = con .CommandText = "select * from [Sheet1$]" End With da.SelectCommand = cmd da.Fill(dt) DataGridView1.DataSource = dt End If Catch ex As Exception MessageBox.Show(ex.Message) Finally con.Close() End Try End Sub