IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

Data type mismatch in criteria expression


Sujet :

VB.NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Étudiant
    Inscrit en
    Mars 2009
    Messages
    90
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2009
    Messages : 90
    Par défaut Data type mismatch in criteria expression
    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

  2. #2
    Membre expérimenté
    Profil pro
    Inscrit en
    Août 2008
    Messages
    310
    Détails du profil
    Informations personnelles :
    Âge : 44
    Localisation : France

    Informations forums :
    Inscription : Août 2008
    Messages : 310
    Par défaut
    Salut,

    Ton champs DateVol est de quel type ? Il se peut que ça bloque là. Et indique nous aussi les autres types de ta table pour que cela soit un peu plus clair ^^

Discussions similaires

  1. [AC-2003] Data type mismatch in criteria expression
    Par Marc_27 dans le forum Requêtes et SQL.
    Réponses: 1
    Dernier message: 23/10/2009, 14h44
  2. Requête avec Data type mismatch in criteria expression
    Par Atom420 dans le forum Requêtes et SQL.
    Réponses: 3
    Dernier message: 01/10/2007, 14h08
  3. Datatype Mismatch in criteria expression
    Par jam92400 dans le forum Access
    Réponses: 2
    Dernier message: 24/06/2006, 17h14
  4. Data Type Mismatch In Criteria Expression
    Par jam92400 dans le forum Access
    Réponses: 10
    Dernier message: 19/06/2006, 10h22
  5. erreur Data type mismatch in criteria expression
    Par bachilbouzouk dans le forum ASP
    Réponses: 3
    Dernier message: 20/04/2005, 11h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo