Author |
Topic  |
pdrg
Support Moderator
    
United Kingdom
2897 Posts |
Posted - 07 May 2007 : 17:09:23
|
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! |
 |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 07 May 2007 : 17:25:46
|
Let me try it now..... |
 |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 07 May 2007 : 17:36:18
|
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 |
 |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 08 May 2007 : 05:57:03
|
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 |
 |
|
AnonJr
Moderator
    
United States
5768 Posts |
Posted - 08 May 2007 : 06:24:29
|
Cool. Glad you got it working. Feels good after all that hard work, doesn't it?  |
 |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 08 May 2007 : 07:07:45
|
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 |
 |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 08 May 2007 : 07:49:08
|
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.
|
 |
|
AnonJr
Moderator
    
United States
5768 Posts |
Posted - 08 May 2007 : 08:11:08
|
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. |
 |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 08 May 2007 : 08:32:31
|
I thought Filtering will take less time and memory instead of closing and reopening a recordset ...5 TIMEs ...
|
 |
|
pdrg
Support Moderator
    
United Kingdom
2897 Posts |
Posted - 08 May 2007 : 08:52:38
|
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?
|
 |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 08 May 2007 : 09:37:38
|
My idea is JUST to get recordcount as of now. |
 |
|
pdrg
Support Moderator
    
United Kingdom
2897 Posts |
Posted - 08 May 2007 : 12:28:25
|
select count (*) from table where <condition> will return a single value, so negligible database-webserver traffic, dbengine can answer count (*) queries without even blinking :) |
 |
|
kolucoms6
Average Member
  
845 Posts |
Posted - 08 May 2007 : 12:43:37
|
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 |
 |
|
pdrg
Support Moderator
    
United Kingdom
2897 Posts |
Posted - 09 May 2007 : 09:02:09
|
Sorry mate, no idea, I'm very much removed from ADO now, last ADO I wrote was 4+ years ago! |
 |
|
AnonJr
Moderator
    
United States
5768 Posts |
Posted - 09 May 2007 : 09:03:43
|
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. |
 |
|
Topic  |
|