[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 390
  • 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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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