Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. 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 Databases 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
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 5th, 2007, 12:41 AM
Authorized User
 
Join Date: Jun 2007
Location: , , .
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Seek help for select Month in list box

Hi,

I need help to select Month and Year in my list box. My database column data type is date/time. My problem is i not sure the way to display "Date" data from database table name "db1" list box value Month and Year in my interface. My purpose is to display recordset in my date data accoding Month and Year select by user. Please help me.
Below is my example code:

<%
    MM=Request.Form("MM")
    yyyy=Request.Form("yyyy")

    mon = Month(date())
    If len(MM)=0 then MM=mon

    Yr = Year(date())
    MinYr = Yr - 2
    MaxYr = Yr††+ 2
    If len(yyyy)=0 then yyyy=Yr
%>

<Form name="frm" method="Post" action="">


<p align="center">Month : <Select name="MM">
<%
    For i = 1 to 12
%>
        <Option Value="<%=i%>" <%If cint(i) = cint(MM) then%> Selected <%End If%>><%=MonthName(i)%></option>
<%
    Next
%>
</Select>


Year : <Select name="yyyy">
<%
    For i = MinYr to MaxYr
%>
        <Option Value="<%=i%>" <%If cint(i) = cint(yyyy) then%> Selected <%End If%>><%=i%></option>
<%
    Next
%>
</Select>

<input type="Submit" value="Submit"> </p>
</Form>
<%
MM=Request.Form("MM")
yyyy=Request.Form("yyyy")
if MM<>"" then
accessdb="Green"


set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("guessbooks.mdb"))
set rsMonth = Server.CreateObject("ADODB.recordset")
sql = "SELECT * FROM db1 WHERE Date = " & MM & " and Date= " & yyyy
rs.Open sql, conn
%>

†There is an error : Error Type:
Microsoft VBScript compilation (0x800A03F6)
Expected 'End'

apple
__________________
apple
Reply With Quote
  #2 (permalink)  
Old October 11th, 2007, 01:11 PM
Friend of Wrox
 
Join Date: May 2006
Location: San Diego, CA, USA.
Posts: 643
Thanks: 0
Thanked 0 Times in 0 Posts
Default

For one thing, this bit of code needs an end if at some point:

Code:
if MM<>"" then
accessdb="Green"
In other words:
Code:
if MM<>"" then
    accessdb="Green" 
    ... other stuff here ...
end if


Woody Z
http://www.learntoprogramnow.com
How to use a forum to help solve problems
Reply With Quote
Reply


Thread Tools
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
Select .. Top 10 by Month? crabjoe SQL Server 2000 17 March 27th, 2008 11:48 AM
multi-column list box values moved to 2nd list box sbmvr Access VBA 1 May 14th, 2007 01:58 PM
multicolored List Box or Select Box sasidhar79 Javascript 1 February 15th, 2005 12:47 AM
select box/List box alphabetic sort sasidhar79 Javascript How-To 3 November 10th, 2004 02:04 AM
Multi Select List Box Coding Errors... snoopy92211 VB Databases Basics 10 June 30th, 2004 08:33 AM



All times are GMT -4. The time now is 02:01 AM.


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