Poblem with recordset
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=22648
Printed Date: 28 March 2026 at 11:07pm Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: Poblem with recordset
Posted By: urko
Subject: Poblem with recordset
Date Posted: 10 February 2007 at 7:46am
Hi guys,
I have small problem.
On may default page i have a calendar. So when u click od certain date on calendar, lets say today's date, it points u to the detail page and should show only records that were made today. However i get all results all the time.
Here's my rs of detail page:
Dim MD MD = Request.QueryString("Ent_Date") SELECT * FROM TEME WHERE 'Ent_Date= "&MD&"' AND Author_ID = " & lngLoggedInUserID & ""
|
Im not exactly sure how to write it so that it will know how to display records for a certain date. When i changed the rs to select by certain ID it worked but when i change it to select by date i get all results from db.
------------- Urko
|
Replies:
Posted By: Scotty32
Date Posted: 10 February 2007 at 11:07am
well looking at that, it seems the part in red is a tad bit off.
Dim MD MD = Request.QueryString("Ent_Date") SELECT * FROM TEME WHERE 'Ent_Date= "&MD&"' AND Author_ID = " & lngLoggedInUserID & "" |
if your going to do text it should be:
Dim MD MD = Request.QueryString("Ent_Date") SELECT * FROM TEME WHERE Ent_Date= '"&MD&"' AND Author_ID = " & lngLoggedInUserID & "" |
and i believe for a date it would be:
Dim MD MD = Request.QueryString("Ent_Date") SELECT * FROM TEME WHERE Ent_Date= #"&MD&"# AND Author_ID = " & lngLoggedInUserID & "" |
------------- S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins
For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .
|
Posted By: urko
Date Posted: 10 February 2007 at 11:34am
Fo some reason, if i add # i get following error:
Syntax error in date in query expression Ent_Date = #9.2.2007#
if i add quotes i get: Data type mismatch in criteria expression.
------------- Urko
|
Posted By: Scotty32
Date Posted: 10 February 2007 at 3:22pm
you need to make the string a valid date, ie: 9/2/2007
you might want to add this:
MD = CDate(Request.QueryString("Ent_Date"))
|
------------- S2H.co.uk - http://www.s2h.co.uk/wwf/" rel="nofollow - WebWiz Mods and Skins
For support on my mods + skins, please use http://www.s2h.co.uk/forum/" rel="nofollow - my forum .
|
Posted By: urko
Date Posted: 11 February 2007 at 10:12am
Hi
Thanks for answer.
I did made it and page loads now, however i always get an empty result. Example. In my db i have datas from today, so when i click on todays date on calendar, i get empy result?
In my db, dates are written DMY 11.2.2007.
do i need to convert the dates on my page as well to get the needed results? and if so, how should i do this.
Not sure, how this works as i never did this kind of thing...I did found some articles agbout that, but no luck thus far.
------------- Urko
|
Posted By: MrMellie
Date Posted: 11 February 2007 at 10:21am
|
A # is only used for delimiting MS Access dates. For SQL Server, use apostrophies ('). You'll also want to put it in international format (20070209 for 9th Feb 2007) or risk having it default to US format when stored in the database.
|
Posted By: urko
Date Posted: 11 February 2007 at 10:25am
ok...i have access db...if i understand you correctly, i need to change the date format to 20070209 in my db as this could be the problem why it's not showing the results ?
------------- Urko
|
Posted By: MrMellie
Date Posted: 11 February 2007 at 11:05am
No sorry, I wasn't clear in what I posted. It's the date format in the SQL string that needs setting that way when using MS SQL.
However, what data type is your date field in Access? If it is set to Date type, then using the format given by Scotty (9/2/2007) in your query should work. That is the format that is used by Access when using the Date data type.
[edit]I just checked an Access db of mine and noticed in a query, the date string is actually in US date format (mm/dd/yyyy) even though in the actual table the date is dd/mm/yyyy. I really hate that assumption that everyone in the world uses US format.
|
|