|
 |
asp_databases thread: Database search & display help needed
Message #1 by "Frode Strømme" <fstroemm@o...> on Sun, 22 Apr 2001 23:59:29
|
|
I need some help doing this or a script that does something similar:
I want to make a page where you can search through an access database with
movies. You can search for either the title or an actor in the movie.
The matches are returned with the name of the movie as a hyperlink. The
hyperlink goes to a page with more detailed information about the movie.
If there is for example more than 25 matches on actor I want the movie
title & links to be displayed over more than one page.
I've read through Beginning ASP 3.0 book, but need some help getting
started with this.
Any help is appreciated.
Thanks.
yours, Frode.
Message #2 by "ASPCoder123" <sahmer@n...> on Mon, 23 Apr 2001 16:19:04
|
|
Check for the "recordcount" property when opening the recordset and if it
is more than 25, use the Paging concept by using the combinations of
Recordset object PageSize and AbsolutePage properties.
Ex.
Dim recordcount
Rs.open "Select * ...",Conn,3,3
If Not Rs.Eof Then
recordcount = Rs.recordcount
If Int(recordcount) > 25 then
'Apply paging
Rs.PageSize = 25 'Max Record to display
Rs.AbsolutePage = Curerentpage 'Display this variable in the Hyperlink
'for page navigation
Else
'Show Page normally
End If
End If
> I need some help doing this or a script that does something similar:
>
> I want to make a page where you can search through an access database
with
> movies. You can search for either the title or an actor in the movie.
> The matches are returned with the name of the movie as a hyperlink. The
> hyperlink goes to a page with more detailed information about the movie.
> If there is for example more than 25 matches on actor I want the movie
> title & links to be displayed over more than one page.
>
> I've read through Beginning ASP 3.0 book, but need some help getting
> started with this.
>
> Any help is appreciated.
>
> Thanks.
>
Message #3 by "Charles Feduke" <webmaster@r...> on Mon, 23 Apr 2001 20:03:48 -0400
|
|
This is very basic, as you said you have a ASP book to refer to. I also
recommend you take a look at the Beginning ASP Databases book (Wrox, ISBN:
1861002726) as it deals alot with Access.
The first thing I would do is create an ODBC reference on the server to
the Access as a System DSN (Control Panel, ODBC Data Sources or something
like that on NT/9X; different on 2000). I only suggest this because it is
the method I learned and seems to be the most versatile if you have to move
from a test server to production. For this example, I will name the DSN
"movies".
Please consider all the basic HTML tags would need to be included as
well in the following examples.
On your search page (search.asp):
<%
Select Case LCase(Request.Form("action"))
Case "" ' display search
%>
<FORM METHOD="POST" ACTION="search.asp">
<INPUT TYPE="hidden" NAME="action" VALUE="search">
<INPUT TYPE="text" NAME="criteria" MAXLENGTH="255" SIZE="20">
<INPUT TYPE="submit" VALUE="Search">
</FORM>
<%
Case "search" ' display results
Dim rsData
Set rsData = Server.CreateObject("ADODB.RecordSet")
rsData.ActiveConnection = "DSN=movies"
rsData.Open "tblMovies", , adCmdTable
' check for no results
If rsData.EOF Then
%>Sorry, there are no matches for your criteria<%
Else
Do Until rsData.EOF
' you'll have to do the 25 count on your own, its not too
hard..
' hint: just pass search as the action and put in a start
parameter and logic
' to determine which record to start displaying at.
Response.Write("<A HREF=""display.asp?id=" & rsData("id") &
""">" & _
rsData("title") & "</A><BR>" & vbCrLf)
rsData.MoveNext
Loop
End If
' clean up
rsData.Close
Set rsData = Nothing
End Select
%>
And here is our display.asp:
<%
Dim rsData
Set rsData = Server.CreateObject("ADODB.Recordset")
rsData.ActiveConnection = "DSN=movies"
rsData.Open "SELECT * FROM tblMovies WHERE id = " &
Request.QueryString("id"), , adCmdText
If rsData.EOF Then
%>Invalid identification number<%
Else
%>
Title: <%=rsData("title")%>
Year: <%=rsData("year")%>
Genre: <%=rsData("genre")%>
<%
End If
' clean up
rsData.Close
Set rsData = Nothing
%>
Some very basic examples that implement a very small range of ASP/ADO
features.
Hope that helps.
- Chuck
----- Original Message -----
From: "Frode Strømme" <fstroemm@o...>
To: "ASP Databases" <asp_databases@p...>
Sent: Sunday, April 22, 2001 11:59 PM
Subject: [asp_databases] Database search & display help needed
> I need some help doing this or a script that does something similar:
>
> I want to make a page where you can search through an access database with
> movies. You can search for either the title or an actor in the movie.
> The matches are returned with the name of the movie as a hyperlink. The
> hyperlink goes to a page with more detailed information about the movie.
> If there is for example more than 25 matches on actor I want the movie
> title & links to be displayed over more than one page.
>
> I've read through Beginning ASP 3.0 book, but need some help getting
> started with this.
>
> Any help is appreciated.
>
> Thanks.
>
> yours, Frode.
|
|
 |