ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 13th, 2003, 08:28 AM
Danbr Danbr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Sertaozinho-SP
Posts: 45 Danbr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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

Reply With Quote
  #2  
Old October 13th, 2003, 07:48 PM
pda8333 pda8333 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 216 pda8333 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 6 m 31 sec
Reputation Power: 5
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)

Reply With Quote
  #3  
Old October 14th, 2003, 05:39 AM
Danbr Danbr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Sertaozinho-SP
Posts: 45 Danbr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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

Reply With Quote
  #4  
Old October 15th, 2003, 12:43 AM
pda8333 pda8333 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 216 pda8333 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 h 6 m 31 sec
Reputation Power: 5
yr welcome danbr. it's a common mistake that can be made by anyone, even myself.

Reply With Quote
  #5  
Old October 16th, 2003, 03:58 PM
Utopia's Avatar
Utopia Utopia is offline
superficial
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Location: Peterborough, England
Posts: 188 Utopia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 8 sec
Reputation Power: 7
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

Reply With Quote
  #6  
Old October 17th, 2003, 05:15 AM
Danbr Danbr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Sertaozinho-SP
Posts: 45 Danbr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > Data type mismatch in criteria expression


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway