Click here to Skip to main content
15,891,850 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
this code i written it gets executed but i won't seen the result on data report


rs.Open "SELECT * FROM tblwith WHERE (((datee) Between # " & DOR & "# And # " & DTPicker1 & "#))", con, adOpenForwardOnly, adLockReadOnly












plz help me
Posted
Updated 31-Oct-13 6:35am
v2
Comments
ZurdoDev 30-Oct-13 13:52pm    
What? That means there is no data, right?

The SQL may execute, but it may not be the SQL you want or expect. You need to see what's being run. Suggest you break out the SQL into a separate variable, put a breakpoint on the fetch and have a look at what's being sent to the DB.

VB
dim queryString as string = "SELECT * FROM tblwith WHERE (((datee) Between # " & DOR & "# And # " & DTPicker1 & "#))"
' Put a break-point on the next line, run the code and look at queryString 
' in the immediate window.
rs.Open  queryString, con, adOpenForwardOnly, adLockReadOnly


Dates are always tricksy. You need to make sure that the client machine and any DB it's talking to aren't using different date formats, especially if you're handing them around as strings. For example, 10/2/2013. In the UK that's the 10th of Feb. in the US it's the 2nd of Oct. and 13/2/2013 might very well result in an error in a US format environment but will cause no problems whatsoever in a UK setup.
 
Share this answer
 
Comments
Snjana143 31-Oct-13 11:55am    
it is not working
Snjana143 31-Oct-13 12:07pm    
Plz send me correct code of this, becoz it is worked but, all the records will be displayed.
you have to use different format for MSACCESS using VB6
like
SELECT * FROM tblwith WHERE (((datee) Between '"#" & DOR & "#"' And '"#" & DTPicker1 & "#"'))"
 
Share this answer
 
Comments
Snjana143 31-Oct-13 12:06pm    
it will not worked
Try this.

SELECT * FROM tblwith WHERE (datee) Between CDate('" & DOR & "') And CDate('" & DTPicker1 & "')


OR Try this

SELECT * FROM tblwith WHERE (datee) >= CDate('" & DOR & "') And (datee) <= CDate('" & DTPicker1 & "')


Hope this will solve your problem
 
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