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 June 22nd, 2004, 12:50 PM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default querying date in db through asp

Hi guys

Just learning about asp etc. I have an access db which has sales budget numbers. I have an asp page that I want to be dynamic so the user can pick a date and find out what the budget for that date (or the sum of many dates) was. (or is).

I am picking up where my predescessor left off...he had a query IN the asp like this:

"SELECT SumOfbudgetAmt FROM qryBudTotalBlock" which worked. It was basically a query of a query (qryBudTotalBlock was a query) It would put the budget numbers from the beginning of the year to the present.

Now..I want to let the user pick the dates. So I added:

"SELECT SumOfbudgetAmt FROM qryBudTotalBlock WHERE budgetDate BETWEEN ' "& Request("fromDate" )&" ' AND ' "&Request("endDate")&" ' "

and it errors. My error is:
Microsoft JET Database Engine error '80040e10'

No value given for one or more required parameters.

newdefault3.asp, line 250

Line 250 is simply the open statement:
rsBudBlock.Open()

I know it's really nothing with the rest of the code, because it worked with the simple query. I'm assuming I'm telling it something wrong??

Can anyone help?

Thanks
Amy
 
Old June 22nd, 2004, 12:56 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

I think for dates in Access you have to do:

"SELECT SumOfbudgetAmt FROM qryBudTotalBlock WHERE budgetDate BETWEEN #"& Request("fromDate" )&"# AND #"&Request("endDate")&"# "

Also, extra spaces between the single quote and the value could cause no results to return, as it literally looks for a space before and after, as such:

' 6/22/2004 '

Brian
 
Old June 22nd, 2004, 01:31 PM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks

Someone else told me the same thing..but that doesn't work either. Now I get the 80040e07 error.

It just doesn't like my statement from BETWEEN on.

Just wondering...the box the user can put in the date (actually, he's forced to use the same syntax as the db)..the box is bigger than the date. Does Access try to read that as 6/21/2004spacespacespacespace? and because there is no date with spacespacespacespace after it..would that cause it to fail?

Amy
 
Old June 22nd, 2004, 01:46 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The error is usually caused by use of incorrect delimiters in your SELECT SQL query statement as mentioned in the earlier post. For Access delimiter is # for date/time field.

after your SQL statement put this code.

Response.Write(YourSQLStatementVariable)
Response.End

and post it.
 
Old June 22nd, 2004, 03:05 PM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Assuming I did this correctly...This popped up on my screen

SELECT SumOfbudgetAmt FROM qryBudTotalBlock WHERE budgetDate BETWEEN #6/21/2004# AND #6/22/2004#

And that's all

So that means it's getting the correct info, just not getting the sum like it should between those two dates, right?

Or am I totally going the wrong direction?
 
Old June 22nd, 2004, 04:25 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Would you post some code? inlcuing SQL for "qryBudTotalBlock "

 
Old June 22nd, 2004, 05:53 PM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi

The boss man just changed his mind on what he wants done..so I'm sure I'll run into other problems along the way, but for now...that problem is solved.

Thanks to all those who responded!

Amy





Similar Threads
Thread Thread Starter Forum Replies Last Post
Need date comparison and month from same db field scottiegirl PHP Databases 13 December 1st, 2007 12:43 PM
Using "." while querying database..asp gives error Shuchik Classic ASP Basics 2 September 17th, 2007 02:47 AM
Finding the DB Sailor.mdb of Beginning ASP DB book anna Classic ASP Databases 2 August 5th, 2006 01:13 PM
Tring to insert date into SQL server Db srjordan Classic ASP Databases 1 August 15th, 2005 06:57 PM
date update from db keyvanjan Classic ASP Databases 0 May 6th, 2005 02:41 AM





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