Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,194,919 members, 7,956,450 topics. Date: Monday, 23 September 2024 at 12:13 PM

Asp Classic To Search For Records Between Two Dates - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Asp Classic To Search For Records Between Two Dates (5193 Views)

C# - Capturing File Name From A FileUpload Control In Asp.net / Tutorial: How To Return Html In Json Response Using Asp.net And Jquery / Vb 6.0 Codes To Trap And Compare Dates (2) (3) (4)

(1) (Reply)

Asp Classic To Search For Records Between Two Dates by gooboy(m): 4:13pm On Feb 24, 2011
Hi all,

Im a beginner in ASP programming n MS SQL server. I created a table named DataReport in SQL server with the following colom
1. Date
2. Item
3. Location
4. Rate
5. Price

I created an HTML form page with three imput fields namely, Location, Datefrom, and Dateto. What I want to achiev is dat when user enter a location and the date from and date, then submit the form, an ASP page will show to display the data from the location selected and within the dates input in the form field. However, all records in the table were displayed regardless of location typed or date range selected.

below is my ASP code


<%


Set oCon = Server.CreateObject ("ADODB.Connection"wink
oCon.Open "Provider=sqloledb;Data Source=RESEARCH\SQLEXPRESS;Initial Catalog=smarta;User Id=sa;Password=10010;"

Set Rec = Server.CreateObject ("ADODB.Recordset"wink


search = request.querystring("search"wink
location = request.form("slocation"wink
datefrom = request.form("datefrom"wink
dateto = request.form("dateto"wink

if agent <> "" then

SQL = "SELECT * FROM DataReport WHERE location like '%" & slocation & "%' AND DATE BETWEEN #" & Format(datefrom,"mm/dd/yyyy"wink & "# and #" & Format(dateto,"mm/dd/yyyy"wink & "#;"




else

SQL = "SELECT * FROM DataReport ORDER BY Item" & sort
End if
Rec.Open SQL, oCon

if Rec.EOF OR Rec.BOF Then
response.write "<br><br>"

response.write "<p align=center><b>No Records Found , </b></p>"

end if


Do While Not Rec.EOF
'AND DisplayNum < 5
r = n Mod 2
if r <> 0 then
'rowBColor = "#99CCFF"
rowBColor = "white"
else
'rowBColor = "#CCFFFF"
rowBColor = "#FFFFFF"
end if

If Rec("DATE"wink < Date-3 then
rowColor = "Red"
else If Rec("DATE"wink < Now()-2 then
rowColor = "Blue"
else
rowColor = "Green"
end if
end if

response.write("<tr>"wink
response.write("<td bgcolor="& rowBColor&">" & Rec("Item"wink& "</td>"wink
response.write("<td bgcolor="& rowBColor&">" & Rec("Location"wink & "</td>"wink
response.write("<td bgcolor="& rowBColor&">" & Rec("rate"wink & "</td>"wink
response.write("<td bgcolor="& rowBColor&">" & Rec("price"wink & "</td>"wink
response.write("<td bgcolor="& rowBColor&">" & Rec("total"wink & "</td>"wink
response.write("<td bgcolor="& rowBColor&">" & Rec("Status"wink & "</td>"wink
response.write("<td bgcolor="& rowBColor&">" & Rec("Approved"wink & "</td>"wink
response.write("<td bgcolor="& rowBColor&">" & Rec("date"wink & "</td>"wink

%>
<% rec.MoveNext
Loop
%>


Pls I will be happy if I can get way out to this problem
Re: Asp Classic To Search For Records Between Two Dates by gooboy(m): 1:32pm On Mar 02, 2011
Yeah, I did it successfully

Tank God

(1) (Reply)

Learn Coding For Free, With Microverse, Pay The Tuition When You Start Earning. / Do you Need A Very Cheap Hosting For A Small Web Project? Just 2k / Please Any Php/mysql Developers Whatsapp Group Out There?

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 18
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.