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 40 41 42 43 44 45 46 47 48 49
|
Dim requete As String = vbEmpty
Dim nom_fichier As String = vbEmpty
If Radio_Btn_Date.Checked = True Then
requete = "select * [Excel 8.0;" & _
"Database=" & Chemin_XLS & "\" & nom_fichier & "].[" & "Resultat requete" & "] from Boites where date_boite between #" & Me.DTP_Date_Depart_Rapport.Value.Date & "# and #" & Me.DTP_Date_Fin_Rapport.Value.Date & "# order by date_boite"
nom_fichier = "Liste_Entitees_Date_Debut_Fin_" & System.DateTime.Now & ".xls"
ElseIf Radio_Btn_Tout.Checked = True Then
requete = "select * [Excel 8.0;" & _
"Database=" & Chemin_XLS & "\" & nom_fichier & "].[" & "Resultat requete" & "]from Boites order by date_boite"
nom_fichier = "Liste_Complete_Entitees_" & System.DateTime.Now & ".xls"
ElseIf Radio_Btn_Erreurs.Checked = True Then
requete = "select * [Excel 8.0;" & _
"Database=" & Chemin_XLS & "\" & nom_fichier & "].[" & "Resultat requete" & "] from Boites order by date_boite where probleme = " & True & ""
nom_fichier = "Liste_Entitees_En_Probleme_" & System.DateTime.Now & ".xls"
End If
' Mode non connecté
Dim strCon$ = CStr("provider=microsoft.jet.oledb.4.0;" & "data source= " & chemin & BD & ";")
Dim CnRapp As New OleDb.OleDbConnection
Dim CmdR As OleDb.OleDbCommand
Dim DtAdapteurRapp As New OleDb.OleDbDataAdapter
Dim DtsetRapp As New DataSet()
CnRapp.ConnectionString = strCon
CnRapp.Open()
CmdR = CnRapp.CreateCommand() 'Creation de commande
'Transfert les données d'Access vers Excel
CmdR.CommandText = requete
Try
DtsetRapp = New DataSet
DtAdapteurRapp = New OleDb.OleDbDataAdapter
DtAdapteurRapp.SelectCommand = CmdR
DtAdapteurRapp.Fill(DtsetRapp, "Boites")
CmdR = Nothing
CnRapp = Nothing
DtsetRapp = Nothing
DtAdapteurRapp = Nothing
Catch
CmdR = Nothing
CnRapp = Nothing
DtsetRapp = Nothing
DtAdapteurRapp = Nothing
End Try |
Partager