Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm creating a Raffle Program using VB6.
I'm having trouble updating the data in MDB. This is the error when executing the SQL
Data type mismatch in criteria expression.
SQL
UPDATE WINNERS SET PrizeClaimed='1' WHERE RaffleNumber=461 AND [Date]='11/21/2012 11:12:52 PM'; 


This is the query I use in adding the record. Don't know why the above SQL won't run. I just add record using the same dates '11/21/2012 11:12:52 PM'
SQL
INSERT INTO WINNERS([RaffleNumber], [PrizeClaimed], [Date]) VALUES('461', '0', '11/21/2012 11:12:52 PM');


Can anyone post why this happens...

Thanks
Posted

I try experimenting
I use this # and it works
SQL
UPDATE WINNERS SET PrizeClaimed='1' WHERE RaffleNumber=461 AND [Date]=#11/21/2012 11:12:52 PM#; 
 
Share this answer
 
It appears your INSERT statement has the values as strings, and the UPDATE as Raffle Number is a number,

Try

SQL
UPDATE WINNERS SET PrizeClaimed='1' WHERE RaffleNumber='461' AND [Date]='11/21/2012 11:12:52 PM'; 


See if that helps.
 
Share this answer
 
Comments
hansoctantan 22-Nov-12 2:35am    
same error occur... :(
Always use # when using dates.
eg #21/03/2012#
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900