Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4
This is the forum to discuss the Wrox book Beginning Dreamweaver MX by Charles E. Brown, Imar Spaanjaars, Todd Marks; ISBN: 9780764544040
Please indicate which version of the book you are using when posting questions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 12th, 2004, 10:10 AM
Authorized User
 
Join Date: Sep 2003
Location: Newmarket, , United Kingdom.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 13 recordset edit


Hi Imar

Happy New Year - hope it has started well for you. I am trying to get back to the footie project I started last year from your book. All's well until p472, and I'm not sure if the problem is to do with the Dreamweaver code, a weird glitch or MS Access. Basically when I edit the recordset so that it uses the variable 'Today' that we create, it only finds records if their end date in the Events table is 01/12/2004 or later, instead of finding all records that are current.

The code I have in Dreamweaver is as follows:
<%
Dim rsEvents
Dim rsEvents_numRows

Set rsEvents = Server.CreateObject("ADODB.Recordset")
rsEvents.ActiveConnection = MM_connFootballSite_STRING
rsEvents.Source = "SELECT EndDate, ID, StartDate, Summary, Title FROM Events WHERE Category = " + Replace(rsEvents__MMColParam, "'", "''") + " AND EndDate >= #" + Replace(rsEvents__Today, "'", "''") + "# ORDER BY StartDate ASC"
rsEvents.CursorType = 0
rsEvents.CursorLocation = 2
rsEvents.LockType = 1
rsEvents.Open()

rsEvents_numRows = 0
%>

have you any ideas?

Thanks
Anne

  #2 (permalink)  
Old January 12th, 2004, 11:02 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi Anne,

New year didn't start too well, unfortunately. Instead of the party I planned to go to, I spent New Year in bed and on the couch because I had the flu :-( That's gone completely now, so I feel much better.

No ideas yet. Can you post the outcome for the SQL statement?

That is, change the code to this:
Code:
rsEvents.Source = "SELECT EndDate, ID, StartDate, Summary, Title  FROM Events  WHERE Category = " + Replace(rsEvents__MMColParam, "'", "''") + " AND EndDate >= #" + Replace(rsEvents__Today, "'", "''") + "#  ORDER BY StartDate ASC"
rsEvents.CursorType = 0
Response.Write("SQL is " & rsEvents.Source)
Response.End
This will write out the entire SQL statement, so it's easier to see what exactly you're passing to the database.

On second thought, what do you mean with "current records". You *are* querying records that have their end date greater than or equal to today, right?

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #3 (permalink)  
Old January 12th, 2004, 11:14 AM
Authorized User
 
Join Date: Sep 2003
Location: Newmarket, , United Kingdom.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello again

Sorry to hear about the flu... it's pretty inevitable this time of year, though, isn't it?! Hope you are feeling better now.

Here is the result of the Response.Write for the SQL statement:

SQL is SELECT EndDate, ID, StartDate, Summary, Title FROM Events WHERE Category = Category AND EndDate >= ## ORDER BY StartDate ASC

and, yes, I can confirm that by 'current records' I mean those that have an end date of at least after today's date.

Thanks for any further help
Anne
:)

  #4 (permalink)  
Old January 12th, 2004, 11:24 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Yeah, I think it was inevitable, although I don't think I ever had it so bad. In fact, looking back I don't think I ever had the flu before.

Anyway, feeling much better now so I can look at your query with a clear mind and this is what I see:

 AND EndDate >= ## ORDER BY StartDate ASC

There is no end date in the query. It's supposed to get its value from rsEvents__Today, but that variable apparently doesn't have a value. Where is it declared in your code? Did you correctly assign it a value of Today() in the Recordset designer dialog?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #5 (permalink)  
Old January 12th, 2004, 12:00 PM
Authorized User
 
Join Date: Sep 2003
Location: Newmarket, , United Kingdom.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello again Imar

Here is a link to a screen capture of my dialog box for the Recordset designer. I've looked at it so many times now I may be missing something obvious to a new pair of eyes, but I can't see an error.

http://www.blueviolet.co.uk/images/recordset.jpg

I *think* it is the same as your instructions? But for me it just isn't working, unless the end date in the relevant database column is 1/12/2004 or later.

Thanks for your help!
Anne
:)



  #6 (permalink)  
Old January 12th, 2004, 12:13 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Yeah, that looks good to me.

How does the code that gets generated look like? You should have something like this:
Code:
<%
Dim rsEvents__Today
rsEvents__Today = "1/1/2100"
If (Date() <> "") Then 
  rsEvents__Today = Date()
End If
%>
Do you have that somewhere? Does Date() return a valid value? You can test that by changing the code to
Code:
:<%
Dim rsEvents__Today
rsEvents__Today = "1/1/2100"
If (Date() <> "") Then 
  rsEvents__Today = Date()
  Response.Write("Date is " & rsEvents__Today)
End If
%>
But again, you say: "unless the end date in the relevant database column is 1/12/2004 or later"

Isn't this the expected behavior? You *are* limiting the records in your database to those that have an End date that is equal to or larger than today.

So, only the events that are still going on, or take place in the future are queried from the database. Or are you trying to accomplish something else?

Is 1/12/2004 the 12th of January or December 1st for you?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #7 (permalink)  
Old January 12th, 2004, 12:24 PM
Authorized User
 
Join Date: Sep 2003
Location: Newmarket, , United Kingdom.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I never thought about that date configuration thing... I assumed 1/12/2004 to be 1 December 2004, as it is surely logical that a day is a part of a month is a part of a year. Maybe that is the problem, and somehow that weird and confusing American date formatting has crept in somewhere?

I will also try your test for the code. Thanks again

Anne
:)

  #8 (permalink)  
Old January 12th, 2004, 12:35 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Ha, finally someone else who doesn't understand American dates.... ;)

I always have the same problem. Here in the Netherlands, 11-01-2004 means January 11, not November first. So I always get confused with the American date format too. In the book we have used the American date format, so code examples / dates are in MM/DD/YYYY format.

I guess that's what is causing the problems in your situation. First you need to make sure that your dates in Access are setup correctly. Try to change a date to an "impossible" value, like 01/16/2004 and see how access saves the date. Then make sure that your other dates stick to the same format.

If you're running ASP on the same server as the database, this example should work. If it doesn't work correctly, you can decide to change the format of the date to something that the database understands. If you want to know how that's done, check out the beginning of Chapter 13 where changing the Display format of the date is discussed (Dynamic Text on the Server Behaviors panel).

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
  #9 (permalink)  
Old January 13th, 2004, 11:43 AM
Authorized User
 
Join Date: Sep 2003
Location: Newmarket, , United Kingdom.
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for your further comments, Imar. As a fellow European, I have never understood the seemingly illogical American way of expressing dates. It just seems to be another change for the sake of change, rather than having any logic to it. And it really does play havoc with any programming issues, doesn't it! oh well...

so, are you looking forward to having Ruud van N back from us in the UK for a while this summer for Euro 2004? If England get knocked out, I have to say I'll be supporting Netherlands as my adopted team!
:);)

  #10 (permalink)  
Old January 13th, 2004, 12:21 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Yes, I am. I think the quality of the (arrogant??) Dutch team is so lousy at the moment, we need guys like Ruud to have at least the slightest chance of making it to the next round.... Oh well.... ;)

Is your date problem solved? Another option you may try is to convert the date to an ISO format: CCYYMMDD. It more or less follows the same logic as your date scheme (i.e. a century has years, which has months which has days) and there shouldn't be a question about what means what. SQL Server is quite capable of handling dates in this format, and I always try to use this format as much as possible. Not sure if it works for Access though.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 13 bwoll BOOK: Beginning Access 2003 VBA 1 June 7th, 2007 03:57 PM
problem in chapter 13 derrida BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 3 July 28th, 2006 02:31 AM
Chapter 13 ElMorenito BOOK: Beginning ASP 3.0 0 January 14th, 2005 02:56 PM
Chapter 13; Using Recordset question ou812 BOOK: Beginning ASP 3.0 2 November 7th, 2003 12:53 PM



All times are GMT -4. The time now is 09:37 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.