Click here to Skip to main content
15,893,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys am running through a problem. i hope this can be solve from here,
I have an SQL Query like
SELECT DC_DATE,DC_UID,DC_TIME,@P3 FROM DAYCLOSE WHERE DC_DATE >=@P1 AND DC_DATE <=@P2

cmd.ExecuteReader()

error DataType Mismatch in Criteria Expression
Posted

@P1 and @P2 must be dates. if these are text you must use
convert(@P1 as datetime)
 
Share this answer
 
How are @P1 and @P2 declared?
Seems like their the wrong datatype in regard to DC_DATE.
You could try:
WHERE DC_DATE BETWEEN TO_DATE(@P1,'mm-dd-yyyy') AND TO_DATE(@P2,'mm-dd-yyyy')

and make sure @P1 and @P2 are the same type/format.
 
Share this answer
 
Hi guys thnk u for ur reply
Parameters are created dynamically based on no of parameters using the statement

for i as byte = 0 to dro("TR_NO_PARAM")-1

Dim p1 As New OleDbParameter(@P1,arrpr(i))
cmd.parameters.Add(P)

Next

if no of param is 2 then it work niceley
ie. P1="28-Jul-2007" {String}
P2="28-Jul-2007" {String}
its not working when we use third parameter
P3="DMALU"{String}
 
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