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
| Private Sub CommandButton1_Click()
'Déclaration de variable
Dim cnn As New ADODB.Connection, rst As New ADODB.Recordset
Dim MaCommand As ADODB.Command
Dim Num_OL As Double
Dim Num_SAP As String
Dim Text_SQL As String
' Ouverture de la connexion à la base de donnée
cnn.Open "ODBC;SERVEUR=sql.serveur_peofofo.com;DSN=peofofo;"
'cnn.Open "ODBC;DATABASE=test;DSN=easyphp;"
champ_1 = Cells(1, 2).Value
champ_2 = Cells(1, 3).Value
champ_3 = Cells(1, 4).Value
champ_4 = Cells(1, 5).Value
champ_5 = Cells(1, 6).Value
If Num_OL = 1 Then
'Requète pour insérer une ligne de commande
Text_SQL = "INSERT INTO essai VALUES (null," & champ_1 & " ," & champ_2 & ", " & champ_3 & ", " & champ_4 & " ," & champ_5 & ")"
Set MaCommand = New ADODB.Command
MaCommand.ActiveConnection = cnn
MaCommand.CommandText = Text_SQL
Set MonRs = MaCommand.Execute(, , adAsyncExecute)
Else
T$ = "Attention" 'Titre du message
M$ = "Probème avec le compte de " & Num_OL 'Message à afficher
Reponse% = MsgBox(M$, 0 + 48, T$)
End If
cnn.Close 'Fermeture de la connection à la base de donnée
End Sub |
Partager