Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 7th, 2004, 08:14 AM
Registered User
 
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Please help - Database problems!


I am currently making a calender and I want to make it so when a user selects a month from the drop down menu it tells them the events for that month (taken from an Access database). Does any body know how I can do this.

Thankyou

Josh
 
Old July 7th, 2004, 08:42 AM
Registered User
 
Join Date: Jul 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thankyou :D

 
Old July 7th, 2004, 08:43 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to madhukp
Default

You need to have a table tblEvents with atleast following fields.

EventName

EventDescription

EventDate

Then in the onChange event of the month dropdown, you can submit the selected month to a page, say events page. Let cboMonth be the name of the drop down. The values of options of cboMonth goes from 1 to 12.

In events page, you can write the script as below.

dim qryGetEvents
dim rstGetEvents
qryGetEvents="SELECT EventName, EventDate FROM tblEvents WHERE MONTH(EventDate)=" & Request.Form("cboMonth")
Set rstGetEvents=Server.CreateObject("ADODB.RecordSet" )
rstGetEvents.Open qryGetEvents, connection_object, adOpenForwardOnly
if(not(rstGetEvents.Eof or rstGetEvents.Bof)) then
    rstGetEvents.MoveFirst
    While(not(rstGetEvents.Eof))
        Response.Write rstGetEvents("EventName") & " on " & cstr(rstGetEvents("EventDate")) & "<br><br>"
        rstGetEvents.MoveNext
    Wend
else
    Response.Write ("There are no events in " & monthname(Request.Form("cboMonth")))
end if
rstGetEvents.Close
Set rstGetEvents=Nothing

In this piece of code connection_object is the connection object which points to your database. The setting of this will depend on the particular database and driver you plan to use.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Searchbar and Database problems gh64 Access 2 January 12th, 2007 11:04 AM
Problems with database saif44 ASP.NET 2.0 Professional 2 November 19th, 2006 06:40 AM
problems connecting to a database allee_man VB Databases Basics 0 December 22nd, 2004 01:05 PM
Database Entry Problems gmoney060 Classic ASP Databases 4 November 9th, 2004 08:19 AM
Problems with database Qing JSP Basics 0 July 7th, 2003 09:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.