Link to home
Start Free TrialLog in
Avatar of aaxen
aaxen

asked on

error message displaying "data type mismatch in criteria expression"

I am unable to update, delete and search can someone have a look of my query...?
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim cmd As New OleDbCommand
        Try
            Dim conn As New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = \\prs-store3.unv.wlv.ac.uk\home2$\0715626\names.mdb")
            conn.Open()
            cmd.Connection = conn
            cmd.CommandType = CommandType.Text
            cmd.CommandText = "update nametable set name='" + TextBox1.Text + "',roll='" + TextBox2.Text + "',address='" + TextBox3.Text + "' where roll='" & TextBox4.Text & "'"
            cmd.ExecuteNonQuery()
            conn.Close()
            MsgBox(" your data has been updated successfully")
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

Open in new window

Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

when the field [roll] is numerical data type, remove the single quotes around the value:

where roll= " & TextBox4.Text & " "
ASKER CERTIFIED SOLUTION
Avatar of Sancler
Sancler

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial