|
BeTheBall -> RE: Querying Comma Separated Values (5/28/2004 22:03:00)
|
Let's go with some pure ASP as I am not sure I can get the DRW to do what I want. So have the form where the user enters the dates submit to a new page. Call it ReservationForm.asp. Create a new page. At the top, insert this code: <% Dim conntemp, myDSN, myRS, mySQL, arrCampSite Set conntemp=Server.CreateObject("ADODB.Connection") myDSN ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("/trishores-scouts/fpdb/NameofyourDB.mdb") conntemp.open myDSN mySQL = "SELECT CampSite FROM WETASKIWIN1 WHERE ([DateStart] Between #::DateStart::# And #::DateEnd::#) OR ([DateEnd] Between #::DateStart::# And #::DateEnd::#) " Set myRS = Server.CreateObject("ADODB.Recordset") myRS.Open mySQL, conntemp, 0, 1 If myRS.eof OR myRS.bof then RecordFound=0 Else arrCampSite = myRS.getrows() RecordFound=-1 End if myRS.Close Set myRS = nothing conntemp.Close Set conntemp = nothing %> Then, after the <body> tag, insert this: The following campsite(s) is/are reserved for the day(s) you selected:<br><br> <% If RecordFound then For Each i in arrCampSite Response.Write i & "<br>" Next else Response.Write("All sites are available") End if %> Then save the page as ReservationForm.asp. Let's take it to there. Test the page by entering dates where you know there are reservations in the db. When you do, you should get a list of all reserved campsites. Then enter dates where you know all sites are available, when you do you should see "All sites are available". Once we get that working, we will move on.
|
|
|
|