Click here to Skip to main content
11,484,640 members (58,520 online)
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 5: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 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... :(
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Always use # when using dates.
eg #21/03/2012#
  Permalink  

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

  Print Answers RSS
0 Maciej Los 190
1 Sergey Alexandrovich Kryukov 170
2 Raje_ 155
3 OriginalGriff 147
4 Mehdi Gholam 120
0 Sergey Alexandrovich Kryukov 8,484
1 OriginalGriff 7,948
2 Sascha Lefèvre 3,199
3 Maciej Los 2,681
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web04 | 2.8.150520.1 | Last Updated 2 Dec 2012
Copyright © CodeProject, 1999-2015
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