Hi all

Sorry- The title was wrong, My problem is when I type a the ID number in the text box for updating the record, it gives me an error "Data type mismatch in criteria expression."

Could anyone help me please in solving this problem?

This is my update code.

cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\HRIS.mdb;")
        cn.Open()
        Dim strupdate As String

        strupdate = "update Employees set [Name] ='" & txtName.Text & "',Mobile ='" & txtMob.Text & "',Home_Phn ='" & txtHomePhn.Text & "',Date_Birth ='" & txtAge.Text & "',CPR='" & txtCPR.Text & _
        "', Address='" & txtAdd.Text & "',email='" & txtEmail.Text & "',Date_hiring='" & txtWorkDate.Text & "',Department='" & txtDep.Text & "',basic_salary='" & txtSal.Text & "'where ID='" & txtSearch.Text & "'"

        cmd = New OleDbCommand(strupdate, cn)
        cmd.ExecuteNonQuery()
        cn.Close()

Thanks in Advance :)

Hi nanoh2001,

I believe your problem is the fact that you are trying to update all fields in your table with string values. If the fields in the table are not all strings then you will get the error you are geting.

I notice that there is a date field you are updating. If this field is a date field and the value you are supplying is not in a valid date format, then the error you are gettting will be generated.

Dear Vandamn,

Thanks for your fast valuable response. I'm sure that I put valid date entries in both birthdate and hiring date,

Yes you are right, I think vb considers any input from textboxes as string, but what can I do?

How can I solve this problem? I tried to convert the "ID" to intiger in "Delete record code form" using Cint function but it doesn't work :(
it gave me the same error,

please help

Does the ID contain characters as well as numbers, or invalid "white space" characters such as <space>.

If not can you post the code in cluding the Cint function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.