Data type mismatch in criteria expression.

Posted by Akj under VB.NET on 9/12/2014 | Points: 10 | Views : 1266 | Status : [Member] | Replies : 2
Hi,

I have created a table in access which has a showdate field which is of date/time data type.

When I try to select the showDate field using query, it shows "Data type mismatch in criteria expression."

Code is given below.

SELECT [seatno] FROM [TicketBookingtable] WHERE (([theatreName] = '" & Session("theatreName").ToString() & "') AND ([movieName] = '" & Session("movieName").ToString() & "') AND ([showDate] = '" & Session("bookedDate").ToString() & "') AND ([showtime] = '" & Session("showTime").ToString() & "'))


Please help.




Responses

Posted by: Naveenhcl on: 9/12/2014 [Member] Starter | Points: 25

Up
0
Down
Hi,

First off all I tell you own thing don't use queries in Page wise better to implement procedures and call that in your application it's easy to understand and coming to your thread while passing the value to that it's violating datatype issues please incorporate it with proper datatype while implement the same.

EX:

if you pass string value to datatime field, how it's accepted you need to convert it as per your datatype then only you get proper result.

Hope you get my point...

Akj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/12/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
tweet the below part of code to pass DATE/TIME values instead of String ( i.e. ToString() )

AND ([showDate] = '" & Session("bookedDate").ToString() & "') AND ([showtime] = '" & Session("showTime").ToString() & "'))


Refer
http://stackoverflow.com/questions/16621695/c-sharp-oledbparameter-with-access-datetime-query

Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Akj, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response