Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB6 VB SQL
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.
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'
INSERT INTO WINNERS([RaffleNumber], [PrizeClaimed], [Date]) VALUES('461', '0', '11/21/2012 11:12:52 PM');
 
Can anyone post why this happens...
 
Thanks
Posted 21-Nov-12 4:24am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I try experimenting
I use this # and it works
UPDATE WINNERS SET PrizeClaimed='1' WHERE RaffleNumber=461 AND [Date]=#11/21/2012 11:12:52 PM#; 
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Always use # when using dates.
eg #21/03/2012#
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

It appears your INSERT statement has the values as strings, and the UPDATE as Raffle Number is a number,
 
Try
 
UPDATE WINNERS SET PrizeClaimed='1' WHERE RaffleNumber='461' AND [Date]='11/21/2012 11:12:52 PM'; 
 
See if that helps.
  Permalink  
Comments
hansoctantan at 22-Nov-12 2:35am
   
same error occur... :(

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 676
1 OriginalGriff 385
2 CPallini 240
3 PIEBALDconsult 150
4 Magic Wonder 131
0 OriginalGriff 5,835
1 Sergey Alexandrovich Kryukov 5,198
2 CPallini 4,740
3 George Jonsson 3,167
4 Gihan Liyanage 2,470


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 2 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100