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
|
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim sql As String
Dim sql2 As String
nom = ComboBox1.Value
prenom = ComboBox2.Value
sal = ComboBox3.Value
gar = ComboBox4.Value
.....
'conection a la bse de données
If ComboBox5.Value = "Oui" Then
'Vérif si enregistrement existant
Set rs.ActiveConnection = con
rs.Open " Select * from acteurcorr where Nom ='" & nom & "' and Prenom ='" & prenom & "'and datebut = # " & date1 & "# " ' c'est dtpicker c'est bon cette linge marche bien
' mais if ne marche plus la 1ére instruction s' exécute je met le bloc instrion 'en commentaire l'update marche si j’enlève le commentaire l'insert marche et 'l'update non
'Traitement
If rs.EOF Then '(si pas d'enregistrements)
'insertion
sql = " insert into acteurcorr (Nom,Prenom,Salaire,grade,datedebut,datefinale) Values ('" & nom & "' ,'" & prenom & "','" & sal & "', '" & gar & "','" & datede & "','" & azer & "' )"
con.Execute sql
Else '(au moins un enregistrement)
sql2 = " update acteurcorr set datefinale = '" & datede & "', grade = '" & gar & "' where Nom ='" & nom & "' and Prenom ='" & prenom & "' and datefinale Is Null "
con.Execute sql2
rs.Close
Set rs = Nothing
End If |
Partager