|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Data type mismatch in criteria expression
Hi,
I have tried the other posts but I haven't gotten to solve the trouble. I am trying to update a database called produtos.mdb <% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:\InetPub\wwwroot\Loja\produtos.mdb" cid = Session("myid") %> this is the code to connect to the database. myid is a session variable that holds the id of the register the code will update. The SQL statement: <% sql="UPDATE produtos SET " sql=sql & "nome_produto='" & Request.Form("productName") & "'," sql=sql & "preco_produto='" & Request.Form("productPrice") & "'," sql=sql & "foto_produto='" & Request.Form("productPicture") & "'," sql=sql & "categoria_produto='" & Request.Form("productCategory") & "'," sql=sql & "subcategoria_produto='" & Request.Form("productSubCategory") & "'," sql=sql & "descricao_produto='" & Request.Form("productFullDesc") & "'" sql=sql & " WHERE id_produto='" & cid & "'" conn.Execute sql 'This should execute the SQL command %> All fields in the database are text except Id that is autonumber and descricao_produto that is memo. When I run it I get the message: Error Type: Microsoft JET Database Engine (0x80040E07) Data type mismatch in criteria expression. /Loja/vaidarcerto.asp, line 28 The values passed by the form are correct: POST Data: productName=asd&productPrice=asd&productPicture=asdas&productCategory=asdas&productSubCategory=asd&productFullDesc=asfdasfdafs (note, just random text) Thanks a lot Daniel |
|
#2
|
|||
|
|||
|
hi danbr,
try this Code:
WHERE id_produto=" & cid & ""
__________________
Hope this helps. Mike Royal Selangor Pewter "I have not failed. I've just found 10,000 ways that won't work." - Thomas Alva Edison (1847-1931) |
|
#3
|
|||
|
|||
|
Hey Mike,
I posted this question in mailing list, and they also replied with the same answer you gave me and it now works perfectly! Thanks a lot! Daniel |
|
#4
|
|||
|
|||
|
yr welcome danbr. it's a common mistake that can be made by anyone, even myself.
|
|
#5
|
||||
|
||||
|
Just to sort of conclude(ish)
stringvar = "something" numbervar = 3 '" & stringvar & "' will post 'something' to the db " & numbervar & " will post 3 to the db Strings should have single quotes around them in the final SQL statement and numbers should not. The exact problem above is because a string (e.g. '3', rather than just 3) is being passed to an integer (number) field type. This is what "Data type mismatch" means - Mismatching number/string types for the same field. (in this case) Matt |
|
#6
|
|||
|
|||
|
Hi Matt,
Thanks for this extra HELP. The trouble happened because the book I am using declared ID as non numeric while I declared as numeric. Thanks! Daniel |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Data type mismatch in criteria expression |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|