Bonjour à tous je suis débutant en vb.net et voici que je suis bloqué sur une erreur au niveau de la modification et de la suppression de mes données. J'utilise une connection oledb pour lier une base de donnée access à vb 2008
voici mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
 
Private Sub BtnModifier_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnModifier.Click
        If Me.Txtdatevol.Text = "" Or Me.TxtHeuredep.Text = "" Or Me.Txtheurearriv.Text = "" Or Me.Txtnumpilote.Text = "" _
           Or Me.Txtnumavion.Text = "" Or Me.Txtnumtrajet.Text = "" Then
 
            MessageBox.Show("Vous devez remplir tous les champs !", "Erreur...", MessageBoxButtons.OK, MessageBoxIcon.Error)
 
            Me.Cmbpilote.Focus()
 
            Exit Sub
 
        End If
        Txtdatevol.Format = DateTimePickerFormat.Short
 
        '
        'strSQL = "UPDATE personnes SET nom='" & txtNom.Text & "', prenom='" & txtPrenom.Text & "', tel='" & txtTel.Text & "', email='" & txtEmail.Text & "' WHERE id=" & lblId.Text
        '
        Ocommande.CommandText = "UPDATE EFFECTUER set Heuredep ='" & TxtHeuredep.Text & "', Heurearriv ='" & Txtheurearriv.Text & "' WHERE Numpilote = '" & Txtnumpilote.Text & "' AND Numavion = '" _
        & Txtnumavion.Text & "' AND Numtrajet = '" & Txtnumtrajet.Text & "' AND Datevol = '" & Txtdatevol.Text & "'"
        Ocommande.Connection = Oconnexion
        Try
            'Oconnexion.Open()
            Ocommande.ExecuteNonQuery()
            MsgBox(" Modification réalisée pour EFFECTUER")
        Catch ex As OleDb.OleDbException
            MsgBox(ex.ToString)
            Exit Sub
        End Try
        Ocommande.CommandText = "SELECT Numpilote, Numavion, Numtrajet, Datevol, Heuredep, Heurearriv FROM EFFECTUER"
        Odreader = Ocommande.ExecuteReader 'récuperation du resultat de l'exécution de la requête cmd
        Dim i As Integer = 0
        Do While Odreader.Read 'tanque on peut lire un enregistrement
            'DataGridView1.Rows.Add() 'ajout de ligne
            DataGridView1.Rows(i).Cells(0).Value = Odreader(0) 'affichage de colonne
            DataGridView1.Rows(i).Cells(1).Value = Odreader(1)
            DataGridView1.Rows(i).Cells(2).Value = Odreader(2)
            DataGridView1.Rows(i).Cells(3).Value = Odreader(3)
            DataGridView1.Rows(i).Cells(4).Value = Odreader(4)
            DataGridView1.Rows(i).Cells(5).Value = Odreader(5)
            i = i + 1
        Loop
        Oconnexion.Close()
    End Sub
If Me.Txtdatevol.Text = "" Or Me.TxtHeuredep.Text = "" Or Me.Txtheurearriv.Text = "" Or Me.Txtnumpilote.Text = "" _
           Or Me.Txtnumavion.Text = "" Or Me.Txtnumtrajet.Text = "" Then
 
            MessageBox.Show("Vous devez remplir tous les champs !", "Erreur...", MessageBoxButtons.OK, MessageBoxIcon.Error)
 
            Me.Cmbpilote.Focus()
 
            Exit Sub
 
        End If
        Txtdatevol.Format = DateTimePickerFormat.Short
        '
        'strSQL = "UPDATE personnes SET nom='" & txtNom.Text & "', prenom='" & txtPrenom.Text & "', tel='" & txtTel.Text & "', email='" & txtEmail.Text & "' WHERE id=" & lblId.Text
        '
        'Ocommande.CommandText = "update EFFECTUER set heuredep ='" & TxtHeuredep.Text & "', heurearriv ='" & Txtheurearriv.Text & "' WHERE Numpilote = '" & Txtnumpilote.Text & "' AND Numavion = '" & Txtnumavion.Text & "' AND Numavion = '" & Txtnumavion.Text & "'AND Datevol = '" & Txtdatevol.Text & "'"
        Ocommande.CommandText = "DELETE FROM EFFECTUER WHERE Numpilote = '" & Txtnumpilote.Text & "' AND Numavion = '" & Txtnumavion.Text & "' AND Numtrajet = '" & Txtnumtrajet.Text & "'AND Datevol = '" & Txtdatevol.Text & "'"
        Ocommande.Connection = Oconnexion
        Try
            'Oconnexion.Open()
            Ocommande.ExecuteNonQuery()
            MsgBox(" Suppression réalisée pour EFFECTUER")
        Catch ex As OleDb.OleDbException
            MsgBox(ex.ToString)
            Exit Sub
        End Try
        Ocommande.CommandText = "SELECT Numpilote, Numavion, Numtrajet, Datevol, Heuredep, Heurearriv FROM EFFECTUER"
        Odreader = Ocommande.ExecuteReader 'récuperation du resultat de l'exécution de la requête cmd
        Dim i As Integer = 0
        Do While Odreader.Read 'tanque on peut lire un enregistrement
            'DataGridView1.Rows.Add() 'ajout de ligne
            DataGridView1.Rows(i).Cells(0).Value = Odreader(0) 'affichage de colonne
            DataGridView1.Rows(i).Cells(1).Value = Odreader(1)
            DataGridView1.Rows(i).Cells(2).Value = Odreader(2)
            DataGridView1.Rows(i).Cells(3).Value = Odreader(3)
            DataGridView1.Rows(i).Cells(4).Value = Odreader(4)
            DataGridView1.Rows(i).Cells(5).Value = Odreader(5)
            i = i + 1
        Loop
        Oconnexion.Close()
    End Sub
et voici l'erreur qu'il affiche
Data type mismatch in criteria expression.
à System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) à System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) à System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) à System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) à System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) à System.Data.OleDb.OleDbCommand.ExecuteNonQuery() à Voyage.FrmVol.BtnModifier_Click(Object sender, EventArgs e) dans C:\Users\Dymex\Documents\Visual Studio 2008\Projects\Voyage\Voyage\FrmVol.vb:ligne 257 à System.Windows.Forms.Control.OnClick(EventArgs e) à System.Windows.Forms.Button.OnClick(EventArgs e) à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) à System.Windows.Forms.Control.WndProc(Message& m) à System.Windows.Forms.ButtonBase.WndProc(Message& m) à System.Windows.Forms.Button.WndProc(Message& m) à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) à System.Windows.Forms.Application.Run(ApplicationContext context) à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) à Voyage.My.MyApplication.Main(String[] Args) dans 17d14f5c-a337-4978-8281-53493378c1071.vb:ligne 81 à System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() à System.Threading.ThreadHelper.ThreadStart_Context(Object state) à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) à System.Threading.ThreadHelper.ThreadStart()
La table utilisée ici est EFFECTUER(Numpilote, Numavion, Numtrajet, Datevol, Heuredep, Heurearriv)

Merci pour votre aide