Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date problem in SQL server 1

Status
Not open for further replies.

royyan

Programmer
Jul 18, 2001
148
US
I just migrate my database from Access to SQL server. My previous ASP code has problem in communicating with SQL database. Here is my SQL statement:
strSQL = ""
strSQL = strSQL & "select count(Page) as Count, max(Page) as Page1 from PAGEVIEW where "
strSQL = strSQL & "[Date] between #" & fromDate & "# and #" & toDate & "# "
strSQL = strSQL & &quot;and BookID = '&quot; & strBookID & &quot;' and TypeID <> 3 and TypeID <> 5 group by Page order by count(Page) desc, Page&quot;
The error message is:
Microsoft OLE DB Provider for ODBC Drivers error '80040e14'
[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near '#'.

Can anybody tell me what's wrong with my code.

Thanks!
 
SQL Server uses a single quote for dates instead of the #. So just replace all the # with ' and it should work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top