Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 10th, 2006, 01:36 PM
Authorized User
 
Join Date: Dec 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Syntax Error on Date Range

I’m using an ASP to search data from MS Access 2000 and another ASP to display results.

When searching a get this error.

Syntax error in date in query expression ‘dtDate Between #1# and #1#’

Any ideas??

Here’s the SQL in the results page.

<%

Dim Recordset1__MMColParam

Recordset1__MMColParam = "1"

If (Request.QueryString("FromField") <> "") Then

  Recordset1__MMColParam = Request.QueryString("FromField")

End If

%>

<%

Dim Recordset1__MMColParam2

Recordset1__MMColParam2 = "1"

If (Request.QueryString("ToField") <> "") Then

  Recordset1__MMColParam2 = Request.QueryString("ToField")

End If

%>

<%

Dim Recordset1

Dim Recordset1_numRows



Set Recordset1 = Server.CreateObject("ADODB.Recordset")

Recordset1.ActiveConnection = MM_Comments_STRING

Recordset1.Source = "SELECT dtDate, dtTime, Comments FROM tblComments WHERE dtDate Between #" + Replace(Recordset1__MMColParam, "#", "##") + "# and #" + Replace(Recordset1__MMColParam2, "#", "##") + "# ORDER BY dtTime ASC"

Recordset1.CursorType = 0

Recordset1.CursorLocation = 2

Recordset1.LockType = 1

Recordset1.Open()



Recordset1_numRows = 0

%>



Thanks,



 
Old February 12th, 2006, 06:10 PM
Authorized User
 
Join Date: Feb 2006
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

..because Dreamweaver set of default value 1 always ! but 1 is not date !!

Recordset1__MMColParam = "02/01/2006"


Recordset1__MMColParam2 = "02/12/2006"

When searching a get this error if you don't pass parameter !.


Steweb




I don’t Speak English very well, excuse me !

www.steweb.net
 
Old February 13th, 2006, 09:47 AM
Authorized User
 
Join Date: Dec 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The end user will enter the start and end dates on a search page. I can't just put the dates in the code. The code should pull the dates from the search fields on the search page. If the default value for the date cannot be 1 then what should I use?

Thanks,:)

 
Old February 13th, 2006, 12:59 PM
Authorized User
 
Join Date: Feb 2006
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default


If you can't put the dates you must condition your code !

  search only if user pass parameter !

If request.querystring("submit")<> "" Then

Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("FromField") <> "") Then
..
..
ecc

end if

Steweb





I don’t Speak English very well, excuse me !

www.steweb.net
 
Old February 13th, 2006, 01:11 PM
Authorized User
 
Join Date: Dec 2004
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks.






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find a date range between another date rang tayvonne Access 2 August 3rd, 2006 09:50 AM
Date Range Flipflop SQL Language 6 November 25th, 2005 08:36 AM
Need Help With Date Range rpainter Crystal Reports 0 June 20th, 2005 01:01 PM
Help with Date Range PacMed Access 1 February 1st, 2005 12:30 PM
Date Range mrideout BOOK: Beginning ASP.NET 1.0 0 January 2nd, 2005 07:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.