• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 398
  • Last Modified:

select statment using vb.net and access 2000

hi
i have a table in access 2000  (empno,ampname,hiredate) and i am using vb.net forms to build the application ,,, now i want to retrive all the employees who started thier work between 2 dates i tried many select staments like below but they are  not working

com.CommandText = "select * from emp where empdate >= '" & CDate(txtDate1.Text) & "' And empdate <= '" & CDate(txtDate2.Text) &"' ;"

please how can i solve it thanx
0
loay
Asked:
loay
1 Solution
 
bman9111Commented:
try

com.CommandText = "select * from emp where empdate >= " & CDate(txtDate1.Text) & " And empdate <= " & CDate(txtDate2.Text) &""

don't need a ; ever......

u dont need the cdate either could be

com.CommandText = "select * from emp where empdate "'" & txtDate1.Text & " And empdate <= " & txtDate2.Text  &""

0
 
rrbeckerCommented:
Hi loay,

Try this, I think that you will find that it works

com.CommandText = "select * from emp where empdate Between #" & txtDate1.Text  & "# AND #" & txtDate2.Text   & "#"

The pound signs (#) denote a DATE comparison.

Hope this help,

rrbecker
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now