setting ado recordsource at run time

databases United States
  • 19 years ago


    i'm setting a new recordsource on my ado data control at run time but it seems like its not working. . .


    adodc.RecordSource = "select * from EMPLOYEE where EMPLOYEE.DOB between dtpFromDate.value and dtpToDate.value"


    dtpFromDate and dtpToDate  date DTPicker controls on a form.


    this should display the records on a data grid but doesn't.


    pls help
    thanks!

  • 19 years ago

    Quote:
    adodc.RecordSource = "select * from EMPLOYEE where EMPLOYEE.DOB between dtpFromDate.value and dtpToDate.value"


    you need to concantenate the date picker values into the SQL statement.  right now it thinks that is just the name of a field not that it's a control and you want the value if it.


    this is how it should be:
    adodc.RecordSource = "select * from EMPLOYEE where EMPLOYEE.DOB between '" & dtpFromDate.value & "' and '" & dtpToDate.value & "'"


    but one other thing.  Are you using Access or SQL?  if you're using access you'll need this one:
    adodc.RecordSource = "select * from EMPLOYEE where EMPLOYEE.DOB between #" & dtpFromDate.value & "# and #" & dtpToDate.value & "#"


    The # symbols on either side of the date tell Access that between them is a date value.

  • 19 years ago

    thsnks a lot!


    but i'm using a visual foxpro database so i think it should be using "{ }"

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Some people, when confronted with a problem, think "I know, I’ll use regular expressions." Now they have two problems.” - Jamie Zawinski