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
| Dim TotalFacture As Integer
TotalFacture = lbltotpel.Text + lblelagf.Text + lbltailfact.Text + lblplfact.Text
Dim MyConnexion As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & _
"C:****")
Dim Mycommand As OleDbCommand = MyConnexion.CreateCommand()
Dim X As Integer
MyConnexion.Open()
Mycommand.CommandText = "SELECT max(numcontrat), nomcli, nomsal FROM contrat where nomcli = '" & txtnomclient.Text & "' and nomsal ='" & ComboBox_Salarié.Text & "'"
Dim myReader As OleDbDataReader = Mycommand.ExecuteReader 'C'est ici que survient l'erreur
Do While myReader.Read()
X = myReader.GetValue(0)
Loop
myReader.Close()
Try
X = X + 1
Mycommand.CommandText = "INSERT INTO contrat VALUES ('" & X & "', '" & txtdate.Text & "', '" & TotalFacture & "','" & txtnomclient.Text & "','" & ComboBox_Salarié.Text & "')"
Mycommand.ExecuteNonQuery()
Catch ex As Exception
MsgBox("Enregistrement reussi")
End Try
MyConnexion.Close() |