Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Text and Date
 New Topic  Topic Locked
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 3

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 07 May 2007 :  17:09:23  Show Profile  Send pdrg a Yahoo! Message
To be honest I've never really liked filters either, they put all the data-handling work into IIS instead of the dbengine...however that's no excuse for them not working...

Looking at your original code, there's a lot of terms in the filter I can see causing trouble, all down to having to manage quote (") symbols right...

3)RS.Filter = "[AddDate] BETWEEN #" & now() & "# AND #" & DateAdd(""d"", 1, now()) & "#"

Try that - I'm a fan of now() myself for no great reason, date() may be better in your case. You need to double up the quotes on the ""d"" to show it's supposed to be quoted within the string. If not perfect, this will be very close I'm certain!
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 07 May 2007 :  17:25:46  Show Profile

Let me try it now.....
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 07 May 2007 :  17:36:18  Show Profile
Microsoft VBScript compilation error '800a03ee'

Expected ')'

/affnet/Right.inc, line 34

Response.write "<b>" & "[AddDate] BETWEEN #" & now() & "# AND #" & DateAdd(""d"", 1, now()) & "#"
-----------------------------------------------------------------------------^

Why "Expected ')' " near DateAdd(""d"", ??

Edited by - kolucoms6 on 08 May 2007 02:32:41
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 08 May 2007 :  05:57:03  Show Profile
I found this article pretty Good

It WORKED atlast :

DateFilterQry1="CDate([AddDate]) BETWEEN #" & Date() & "# AND #" & DateAdd("d", -1, Date()) & "#"

Edited by - kolucoms6 on 08 May 2007 06:12:33
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 08 May 2007 :  06:24:29  Show Profile  Visit AnonJr's Homepage
Cool. Glad you got it working. Feels good after all that hard work, doesn't it?
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 08 May 2007 :  07:07:45  Show Profile
Yes it feels good.. But I was wrong... It didnt.. :-(

Sorry for the confusion.But NO idea why its NOT working.

Error :

ADODB.Recordset error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/Right.inc, line 36


Line 36 :

DateFilterQry1="CDate([AddDate]) BETWEEN #" & Date() & "# AND #" & DateAdd("d", -1, Date()) & "#"
RS.Filter=DateFilterQry1

Also tried :

DateFilterQry1="CDate([AddDate]) BETWEEN '" & CDate(Now()) & "' AND '" & DateAdd("d", -1, Cdate(Now())) & "'"
RS.Filter=DateFilterQry1


Query which works :
**************************


select * from subcategory where CDate([AddDate]) BETWEEN cdate(now()) and cdate(dateadd("d",-3,now()))



Edited by - kolucoms6 on 08 May 2007 07:23:10
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 08 May 2007 :  07:49:08  Show Profile

Should I forget Filter and use simple query ?


But for that I have to re-OPEN the recordset everytime as I wanted to use this Filter clause 5 times but with different criteria.
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 08 May 2007 :  08:11:08  Show Profile  Visit AnonJr's Homepage
All things being equal, I scarcely ever use the filter. I don't see where hitting the DB 5 times is going to be that big of an issue... though I could be mistaken.
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 08 May 2007 :  08:32:31  Show Profile
I thought Filtering will take less time and memory instead of closing and reopening a recordset ...5 TIMEs ...

Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 08 May 2007 :  08:52:38  Show Profile  Send pdrg a Yahoo! Message
I think your idea about trying to avoid hitting the db 5 times over is good practice, or at least a valid argument, depends on how you're using the data in the end a bit I guess too - cor instance if it's just a count of the records, then it's quite a cumbersome method, but if you're displaying it several ways, it could be quite elegant.

You can also use ADO to request multiple sets of data in one hit, you know, by having the SQL return several recordsets and using rs.nextrecordset() in ASP - works a treat with MSSQL, never tried it with Access http://www.w3schools.com/ado/met_rs_nextrecordset.asp
could this help?

Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 08 May 2007 :  09:37:38  Show Profile

My idea is JUST to get recordcount as of now.
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 08 May 2007 :  12:28:25  Show Profile  Send pdrg a Yahoo! Message
select count (*) from table where <condition> will return a single value, so negligible database-webserver traffic, dbengine can answer count (*) queries without even blinking :)
Go to Top of Page

kolucoms6
Average Member

845 Posts

Posted - 08 May 2007 :  12:43:37  Show Profile
Ok Thanks a lot..

One quick question:

When i run a query in backend access database, I get 4-5 records, but when I run the same query in asp, it returns me ZERO records.

I am using

RS.Open sql, session("cn"),3,3 .

Edited by - kolucoms6 on 09 May 2007 08:14:10
Go to Top of Page

pdrg
Support Moderator

United Kingdom
2897 Posts

Posted - 09 May 2007 :  09:02:09  Show Profile  Send pdrg a Yahoo! Message
Sorry mate, no idea, I'm very much removed from ADO now, last ADO I wrote was 4+ years ago!
Go to Top of Page

AnonJr
Moderator

United States
5768 Posts

Posted - 09 May 2007 :  09:03:43  Show Profile  Visit AnonJr's Homepage
Count returns a number, not a bunch of records. I'm a little rusty on the finer points, but I believe you could use something like:

sql = "SELECT count (*) AS somemeaningfulname FROM table WHERE <condition>"
RS.Open sql, session("cn"),3,3
intCount = RS("somemeaningfulname")

But like I said, I'm a little rusty on the finer points so it could be something a little different.
Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Previous Page | Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.21 seconds. Powered By: Snitz Forums 2000 Version 3.4.07