1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| Private Sub Button5_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click '' importer
Dim OpenFileDialog2 As New OpenFileDialog
DGV.Visible = True
Dim dt As New System.Data.DataTable
If OpenFileDialog2.ShowDialog = System.Windows.Forms.DialogResult.OK Then
Dim FileName As String = OpenFileDialog2.FileName.ToUpper
Dim Builder As New OleDbConnectionStringBuilder With {.DataSource = FileName}
Dim NomFeuille As String
NomFeuille = "code"
' Setup the properties for our connection dependent on which file was open.
Using cn As New System.Data.OleDb.OleDbConnection With {.ConnectionString = Builder.ConnectionString}
Dim cmd As New OleDbCommand With _
{ _
.CommandText = "SELECT * FROM [" & NomFeuille & "$]", _
.Connection = cn _
}
cn.Open()
dt.Load(cmd.ExecuteReader)
DGV.DataSource = dt
DGV.Columns.RemoveAt(0)
End Using
End Sub |