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


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

Posted on 2006-05-24
Medium Priority
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 66

Accepted Solution

Jim Horn earned 150 total points
ID: 16752692
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Loops Section Overview

864 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