Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    sql with between

    I have a table with these

    ...| info | birth | death | ...

    where birth and death represent a range of time

    and a variable

    Dim mydate
    mydate = Date

    with date of my system

    I want select from table only the records where mydate belong to range [birth death]

    ---------------

    sql = "SELECT * FROM table WHERE mydate BETWEEN #"& birth &"# AND #"& death &"#"

    but i have error:

    Microsoft OLE DB Provider for ODBC Drivers errore "80040e14'

    [Microsoft][Driver ODBC Microsoft Access] Errore di sintassi nella data nell'espressione della query 'mydate BETWEEN ## AND ##'.

    I have cheked that birth and death are not empty.

    thank you

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Looks like birth and death are losing the values by the time they get to the SQL statement. Did you Dim them both?

    ALSO, try using single quotes around the value as well, i.e.:

    '" & birth & "'
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #3
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post

    connecting to a SQL db.

    For MS access you connect to a DB using this driver.

    "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & server.mappath("/experiments/data/biblio.mdb") & ";"


    How might I be able to connect to an SQL db?
    What is the code for it?

    It uses ODBC not OLEDB in some way. This is all I know.. anyone help me?
    PLEASE?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •