Bonjour, j'ai un petit problème:
j'ai une table créée sous microsof sql 2008. Je n'ai pas defini la clé de cette table auto-incrementale sous MS SQL je voudrais le faire sous vb 6.0. Pour cela j'ai ma fonction incremente qui me permet d'incrementer la clé. Lorsque je clique sur le bouton Enregistrer(ce bouton execute MAJ_click ci-dessous) il me met en jaune la ligne en gras( Adotypeoperation.Recordset.Update): QUELQU'UPEUT M'AIDER?
Function increment() As Integer
Dim trouver As Boolean
trouver = False
If Adodc1.Recordset.BOF = False Then
Adodc1.Recordset.MoveLast
increment = Adodc1.Recordset.Fields(0)
Else
increment = 0
End If
End Function
Ce code est me permet d'enregistrer lees données dans ma table
Private Sub MAJ_Click(Index As Integer)
Select Case Index
Case 0
If Txtliboperation.Text = "" And Txtmontantseuil.Text = "" Then
MsgBox "Les champs NOM DE L'OPERATION et MONTNANT SEUIL ne doivent pas être null"
ElseIf Txtliboperation.Text = "" Then
MsgBox "le champ NOM DE L'OPERATION ne doit pas être vide"
ElseIf Txtmontantseuil.Text = "" Then
MsgBox "le champ MONTANT SEUIL ne doit pas être vide"
Else:
Adotypeoperation.Refresh
Adotypeoperation.Recordset.AddNew
Adotypeoperation.Recordset.Fields(0) = increment
Adotypeoperation.Recordset.Fields(1) = Txtliboperation.Text
Adotypeoperation.Recordset.Fields(2) = Txtmontantseuil.Text
Adotypeoperation.Recordset.Update
End If
Case 1
............
.......
end sub