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
| Private Sub List1_Click()
'************************************ ajouter *********************
Dim C As Integer, N As Integer
'************************************fin ajouter *********************
N = List1.ListIndex 'evenement selectionné
C = List1.List(N)
'While MFG.Rows > 2
'MFG.RemoveItem (MFG.Rows - 1)
'Wend
'************************************ ajouter *********************
MFG.Rows = 1: MFG.FixedRows = 1
MFG.Cols = 4: MFG.FixedCols = 1
MFG.FormatString = "|Numéro commande |Réf_produits |Quantité produits"
'************************************fin ajouter *********************
Dim DB_connexion As ADODB.Connection
Set DB_connexion = New ADODB.Connection
DB_connexion.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" & "SERVER=localhost;" & " DATABASE=liv;" & "UID=root;PWD=; OPTION=3"
DB_connexion.Open
'************************************ ajouter *********************
If DB_connexion.State = adStateClosed Then
MsgBox "Impossible d'ouvrir la BD", vbCritical, "Problème"
Exit Sub
End If
Dim rsi As ADODB.Recordset
'************************************fin ajouter *********************
Set rsi = New ADODB.Recordset 'recuperation des informtions ds la base
rsi.CursorLocation = adUseServer
rsi.Open "select all num_cmd,ref_pdt,qte_pdt from produits where ref_pdt='" & C & "'", DB_connexion
'************************************ ajouter *********************
If rsi.State = adStateClosed Then
MsgBox "Impossible d'ouvrir la Table", vbCritical, "Problème"
DB_connexion.Close
Exit Sub
End If
If rsi.EOF Then
rsi.Close
DB_connexion.Close
MsgBox "Aucun enregistrement disponnible", vbCritical, "Problème"
Exit Sub
End If
'************************************fin ajouter *********************
Do While Not rsi.EOF 'tant qu'i existe
MFG.Rows = MFG.Rows + 1
MFG.TextMatrix(MFG.Rows - 1, 1) = rsi.Fields("num_cmd").Value
MFG.TextMatrix(MFG.Rows - 1, 2) = rsi.Fields("ref_pdt").Value
MFG.TextMatrix(MFG.Rows - 1, 3) = rsi.Fields("qte_pdt").Value
'MFG.AddItem ""
rsi.MoveNext
Loop
'************************************ ajouter *********************
rsi.Close
DB_connexion.Close
'************************************fin ajouter *********************
End Sub |
Partager