Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Poblem with recordset
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Poblem with recordset

 Post Reply Post Reply
Author
urko View Drop Down
Groupie
Groupie
Avatar

Joined: 23 September 2004
Location: Slovenia
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote urko Quote  Post ReplyReply Direct Link To This Post Topic: Poblem with recordset
    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.


Edited by urko - 10 February 2007 at 7:47am
Urko
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post 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 & ""





Edited by Scotty32 - 10 February 2007 at 11:07am
S2H.co.uk - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
urko View Drop Down
Groupie
Groupie
Avatar

Joined: 23 September 2004
Location: Slovenia
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote urko Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Scotty32 View Drop Down
Moderator Group
Moderator Group


Joined: 30 November 2002
Location: Manchester, UK
Status: Offline
Points: 1682
Post Options Post Options   Thanks (0) Thanks(0)   Quote Scotty32 Quote  Post ReplyReply Direct Link To This Post 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 - WebWiz Mods and Skins

For support on my mods + skins, please use my forum.
Back to Top
urko View Drop Down
Groupie
Groupie
Avatar

Joined: 23 September 2004
Location: Slovenia
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote urko Quote  Post ReplyReply Direct Link To This Post 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.



Edited by urko - 11 February 2007 at 10:12am
Urko
Back to Top
MrMellie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 December 2006
Location: United Kingdom
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote MrMellie Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
urko View Drop Down
Groupie
Groupie
Avatar

Joined: 23 September 2004
Location: Slovenia
Status: Offline
Points: 160
Post Options Post Options   Thanks (0) Thanks(0)   Quote urko Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
MrMellie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 December 2006
Location: United Kingdom
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote MrMellie Quote  Post ReplyReply Direct Link To This Post 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.

Edited by MrMellie - 11 February 2007 at 11:13am
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.