Database

S

Steve

On my site I have a database that holds 250 names and each persons score for
different games. The database works fine. But I want to make it easier for
the person searching for their name by adding a search component. Is there
anyway the visitor could enter there name and it could bring up there scores?
 
S

Stefan B Rusynko

See http://www.asp101.com/samples/db_search.asp

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| On my site I have a database that holds 250 names and each persons score for
| different games. The database works fine. But I want to make it easier for
| the person searching for their name by adding a search component. Is there
| anyway the visitor could enter there name and it could bring up there scores?
 
S

Steve

Thanks for the link.

That code seems a little tricky for me as I am a beginer. Are there any
tutorials that I can read? Any other help?
 
K

Kathleen Anderson [MVP - FrontPage]

http://www.brainbell.com/tutorials/ms-office/FrontPage_2003/The_Database_Results_Wizard.htm

--

~ Kathleen Anderson
Microsoft MVP - FrontPage
Spider Web Woman Designs
web: http://www.spiderwebwoman.com/resources/


Steve said:
Thanks for the link.

That code seems a little tricky for me as I am a beginer. Are there any
tutorials that I can read? Any other help?


Stefan B Rusynko said:
See http://www.asp101.com/samples/db_search.asp

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________


| On my site I have a database that holds 250 names and each persons
score for
| different games. The database works fine. But I want to make it easier
for
| the person searching for their name by adding a search component. Is
there
| anyway the visitor could enter there name and it could bring up there
scores?
 
T

Trevor L.

Steve said:
Thanks for the link.

That code seems a little tricky for me as I am a beginer. Are there
any tutorials that I can read? Any other help?

This is clearly a much required task, but one I haven't yet tried it myself.

So I might see if I can get it working on my simple database. If so, I will
try to post a step-by-step guide.
 
S

Steve

The link is: www.skyhaipoker.ca/standings.asp

No names or scores are plugged into the table yet. At the top of page
(beneath "Overall Standings" title) I want the visitor to have a search
option. They would type there name in a search box and there scores come up.
It beats having to flip through 5 pages to find there scores.
Any help? Thanks!

Trevor L. said:
Steve said:
Thanks for the link.

That code seems a little tricky for me as I am a beginer. Are there
any tutorials that I can read? Any other help?

This is clearly a much required task, but one I haven't yet tried it myself.

So I might see if I can get it working on my simple database. If so, I will
try to post a step-by-step guide.

--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
 
C

Clark

Or, as several have suggested, this is easy to accomplish by your self
using the database resutls wizard. That is what it is *for*

The link is: www.skyhaipoker.ca/standings.asp

No names or scores are plugged into the table yet. At the top of page
(beneath "Overall Standings" title) I want the visitor to have a search
option. They would type there name in a search box and there scores come up.
It beats having to flip through 5 pages to find there scores.
Any help? Thanks!

Trevor L. said:
Steve said:
Thanks for the link.

That code seems a little tricky for me as I am a beginer. Are there
any tutorials that I can read? Any other help?

This is clearly a much required task, but one I haven't yet tried it myself.

So I might see if I can get it working on my simple database. If so, I will
try to post a step-by-step guide.

--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website: http://trevorl.mvps.org/
 
T

Trevor L.

Steve said:
The link is: www.skyhaipoker.ca/standings.asp

No names or scores are plugged into the table yet. At the top of page
(beneath "Overall Standings" title) I want the visitor to have a
search option. They would type there name in a search box and there
scores come up. It beats having to flip through 5 pages to find there
scores.
Any help? Thanks!

Well, I said I would try

The code below does a search on my guestbook (site in my signature)

This page will do the work as is, provided it is saved as an .asp file. You
can put a link to it in your home page (or wherever)

But of course you need to alter it to your needs

1.
I have set strDBPath to an entry in global.asa
Application("guestbook_ConnectionString") = "DRIVER={Microsoft Access Driver
(*.mdb)};DBQ=URL=fpdb/guestbook.mdb"

So you need to set up an entry on global.asa, changing the path to that to
your DB.

I tried simply setting
strDBPath = "DRIVER={Microsoft Access Driver
(*.mdb)};DBQ=URL=fpdb/guestbook.mdb"

but I got this error:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open
registry key 'Temporary (volatile) Jet DSN for process 0x8a0 Thread 0xf74
DBC 0x15faebc4 Jet'.
/search.asp, line 44
where line 44 is
cnnSearch.Open strDBPath

I have idea why. It seems to me that the two are equivalent. Maybe it is
already open or something. I am hoping someone else can give some more info.

2.
Change
<th><b>Name</b></th>
<th><b>Comments</b></th>
<th><b>Timestamp</b></th>
to the titles for the fields you want from your DB

possibly
<th ALIGN="LEFT"><b>Player Name</b></th>
<th ALIGN="LEFT"><b>Dickens</b></th>
<th ALIGN="LEFT"><b>Post Office</b></th>
<th ALIGN="LEFT"><b>Ivy Arms</b></th>
<th ALIGN="LEFT"><b>Bryden's</b></th>
<th ALIGN="LEFT"><b>Total</b></th>

3.
Change
<td valign="top"><%=FP_FieldVal(rstSearch,"name")%></td>
<td valign="top"><%=FP_FieldVal(rstSearch,"comments")%>
<td><%=FP_FieldVal(rstSearch,"Timestamp")%></td>
where the names in "" are those of our fields you want from your DB
(I would only be guessing here as to the field names)

4. The line
<!--#include file="_fpclass/fpdblib.inc"-->
includes a library which is usually generated by the DB wizard.
If you dont have it, I will post it separately

Either that or change the code in 3. to
<td valign="top"><%= rstSearch("name")%></td>
<td valign="top"><%= rstSearch("comments")%></td>
<td valign="top"><%= rstSearch("Timestamp")%></td>
where the names in () are those of our fields

Sorry it seems so complex, but as someone else said, if you use the DB
Wizard it should do what you want


=== This is the code ========
<html>
<!-- search.asp -->

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Search Guestbook</title>
</head>

<%
' Declare our variables... always good practice!
Dim strURL ' The URL of this page so the form will work
' no matter what this file is named.
Dim cnnSearch ' ADO connection
Dim rstSearch ' ADO recordset
Dim strDBPath ' path to our Access database (*.mdb) file
Dim strSQL ' The SQL Query we build on the fly
Dim strSearch ' The text being looked for

' Retrieve the URL of this page from Server Variables
strURL = Request.ServerVariables("URL")

' Set the DB Path
strDBPath = Application("guestbook_ConnectionString")

' Retrieve the term being searched for.
strSearch = Request("search")
%>

<body>
<!--#include file="_fpclass/fpdblib.inc"-->

<p>Search by name. (% returns all)</p>
<form action="<%= strURL %>" method="get">
<input name="search" value="<%= strSearch %>" />
<input type="submit" />
</form>

<% If strSearch <> "" Then
' Create an ADO Connection to connect to the database.
Set cnnSearch = Server.CreateObject("ADODB.Connection")

' Open the connection
cnnSearch.Open strDBPath

' Build our query based on the input.
strSQL = "SELECT * " _
& "FROM Results " _
& "WHERE name LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "ORDER BY name;"

' Execute our query using the connection object.
Set rstSearch = cnnSearch.Execute(strSQL)

' Display a table of the data in the recordset.
%>
<table border="1">
<tr>
<th><b>Name</b></th>
<th><b>Comments</b></th>
<th><b>Timestamp</b></th>
</tr>
<% Do While Not rstSearch.EOF %>
<tr>
<td valign="top"><%=FP_FieldVal(rstSearch,"name")%></td>
<td valign="top"><%=FP_FieldVal(rstSearch,"comments")%>
<td><%=FP_FieldVal(rstSearch,"Timestamp")%></td>
</tr>
<% rstSearch.MoveNext
Loop %>
</table>
<% ' Close our recordset and connection and dispose of the objects
rstSearch.Close
cnnSearch.Close
Set rstSearch = Nothing
Set cnnSearch = Nothing
End If %>

</body>
</html>
======================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top