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
|
Public Class Gestion_Projet_Creation
Private FileName As String = IO.Path.GetFullPath("Feuille de calcul dans Basis (1).xlsx")
Private Connection As OleDb.OleDbConnection = New OleDb.OleDbConnection
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
.....
'' ouverture du fichier Excel avec les données
'
If Not String.IsNullOrWhiteSpace(TextBox2.Text) Then
Dim ConnectionString As String = Connection(FileName)
Using cn As New OleDb.OleDbConnection With {.ConnectionString = ConnectionString}
Using cmd As New OleDb.OleDbCommand With {.CommandText = "SELECT * From [Feuil1]", .Connection = cn}
Using oda As New OleDbDataAdapter()
Dim dt As New DataTable()
cmd.CommandText = (Convert.ToString("SELECT * From [Feuil1]"))
cmd.Connection = cn
cn.Open()
oda.SelectCommand = cmd
oda.Fill(dt)
cn.Close()
'Populate DataGridView.
DataGridView1.DataSource = dt
End Using
End Using
End Using
End If
End Sub |
Partager