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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
| Private Sub btn_rechercher_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_rechercher.Click
Dim libelle_logiciel As String = listder_lib_logi_micro.Text
Dim date_debut As String = Date_deb.Text
Dim date_final As String = Date_fin.Text
Dim cellule As String = listder_lib_logi_micro.Text
Dim type_incident As String = listder_type_incident.Text
Dim domaine_informatique As String = listder_domaine_info.Text
Dim myDSLibLogMi As DataTable = New DataTable
Dim myDSCellule1 As DataTable = New DataTable
Dim MyConnexion As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & _
"lien source")
Dim Mycommand As OleDbCommand = MyConnexion.CreateCommand()
Dim Mycommand1 As OleDbCommand = MyConnexion.CreateCommand()
Dim Mycommand2 As OleDbCommand = MyConnexion.CreateCommand()
Dim Mycommand3 As OleDbCommand = MyConnexion.CreateCommand()
Dim Mycommand4 As OleDbCommand = MyConnexion.CreateCommand()
Dim requete, requete1, requete2, requete3, requete4 As String
MyConnexion.Open()
If Date_deb.Text <> "" And Date_fin.Text <> "" Then
requete = "SELECT DATE_INITIAL FROM HDC_VW_INCIDENTS WHERE DATE_INITIAL between Date_deb.text and Date_fin.text"
Else : MsgBox("Il n'y a pas d'incident à ces dates")
End If
Mycommand.CommandText = requete
Try
Dim myReader As OleDbDataReader = Mycommand.ExecuteReader()
'Erreur: Une exception non gérée du type 'System.Data.OleDb.OleDbException' s'est produite dans system.data.dll'
Do While myReader.Read()
If myReader.IsDBNull(0) = False Then
listder_lib_logi_micro.Items.Add(myReader.GetString(0))
End If
Loop
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
If listder_lib_logi_micro.Text <> "" Then
requete1 = "SELECT DISTINCT (AOP_SDIQWA2.NOM_APPLICATION)FROM AOP_SDIQWA2 WHERE libelle_logiciel"
Else : listder_lib_logi_micro.Text = ""
End If
Mycommand1.CommandText = requete1
Try
Dim myReader1 As OleDbDataReader = Mycommand1.ExecuteReader()
'Erreur: Une exception non gérée du type 'System.Data.OleDb.OleDbException' s'est produite dans system.data.dll'
Do While myReader1.Read()
If myReader1.IsDBNull(0) = False Then
listder_lib_logi_micro.Items.Add(myReader1.GetString(0))
End If
Loop
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
If listder_cellule.Text <> "" Then
requete2 = "Select CC_INITIALE, CELLULE_ASSIGNE FROM HDC_VW_INCIDENTS WHERE cellule"
Else : listder_cellule.Text = ""
End If
Mycommand2.CommandText = requete2
Dim myReader2 As OleDbDataReader = Mycommand2.ExecuteReader()
'Erreur: Une exception non gérée du type 'System.Data.OleDb.OleDbException' s'est produite dans system.data.dll'
Do While myReader2.Read()
If myReader2.IsDBNull(0) = False Then
listder_lib_logi_micro.Items.Add(myReader2.GetString(0))
End If
Loop
If listder_type_incident.Text <> "" Then
requete3 = "SELECT DISTINCT (HDC_VW_INCIDENTS.TYPE) FROM HDC_VW_INCIDENTS WHERE type_incident"
Else : listder_type_incident.Text = ""
End If
Mycommand3.CommandText = requete3
Dim myReader3 As OleDbDataReader = Mycommand3.ExecuteReader()
'Erreur: Une exception non gérée du type 'System.Data.OleDb.OleDbException' s'est produite dans system.data.dll'
Do While myReader3.Read()
If myReader3.IsDBNull(0) = False Then
listder_lib_logi_micro.Items.Add(myReader3.GetString(0))
End If
Loop
If listder_domaine_info.Text <> "" Then
requete4 = "SELECT DISTINCT (HDC_VW_INCIDENTS.DOMAINE) FROM HDC_VW_INCIDENTS WHERE domaine_informatique"
End If
Mycommand4.CommandText = requete4
Dim myReader4 As OleDbDataReader = Mycommand4.ExecuteReader()
'Erreur: Une exception non gérée du type 'System.Data.OleDb.OleDbException' s'est produite dans system.data.dll'
Do While myReader4.Read()
If myReader4.IsDBNull(0) = False Then
listder_lib_logi_micro.Items.Add(myReader4.GetString(0))
End If
Loop
'* affichage d'un résultat dans une page excel *'
Dim myreader5 As OleDbDataReader = Mycommand.ExecuteReader()
Dim xlApp As Excel.Application
Try
xlApp = GetObject(, "excel.application")
Catch
xlApp = New Excel.Application
Finally
xlApp.Visible = False
End Try
'ajout d'une page et sélection
Dim xsIncidents As Excel.Worksheet = xlApp.Workbooks.Add.ActiveSheet
'requete serveur
Try
With Mycommand.CommandText = requete
MyConnexion.Open()
Do While myreader5.Read()
If myreader5.IsDBNull(0) = False Then
listder_lib_logi_micro.Items.Add(myreader5.GetString(0))
End If
Loop
End With
' affichage
xlApp.Visible = True
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub |
Partager