ASP  /  Incorrect syntax near '#' in Between SQL statement

Posted on 2006-05-24
Last Modified: 2010-04-17

ASP ---> I keep getting an error page message. The code doesn't seem to parse or the syntax is incorrect.  Do you know what may be wrong in "Between" statement.  It connects to a SQL Sever DB and I know it checks the tags first ... I don't thinks that I miss place one.  

Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '#'.

  strSQL="Select * From SQLTbl "
   strSQL=strSQL & " Where [call date] between "
   strSQL=strSQL & "#" & varGetStartDate & "# and #" & varGetEndDate & "#"
   Response.Write "<HR>" & strSQL & "<HR>"
   rs.Open strSQL, conn, adOpenStatic

Question by:skyler99
    1 Comment
    LVL 65

    Accepted Solution

    SQL Server uses ' to delineate dates.  Access uses pound signs #.  

    Try this...
    strSQL="Select * From SQLTbl "
    strSQL=strSQL & " Where [call date] between "
    strSQL=strSQL & "'" & varGetStartDate & "' and '" & varGetEndDate & "'"

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    pre4 challenge 19 75
    zeroMAx challenge 20 66
    countClumps  challenge 10 69
    wordappend challenge 8 47
    RIA (Rich Internet Application) tools are interactive internet applications which have many of the characteristics of desktop applications. The RIA tools typically deliver output either by the way of a site-specific browser or via browser plug-in. T…
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now