Wrox Programmer Forums
|
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 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 October 5th, 2007, 12:41 AM
Authorized User
 
Join Date: Jun 2007
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
 
Old October 11th, 2007, 01:11 PM
Friend of Wrox
 
Join Date: May 2006
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





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 01:47 AM
select box/List box alphabetic sort sasidhar79 Javascript How-To 3 November 10th, 2004 03:04 AM
Multi Select List Box Coding Errors... snoopy92211 VB Databases Basics 10 June 30th, 2004 08:33 AM





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