Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

search library system in asp

0 views
Skip to first unread message

amoona

unread,
Aug 13, 2003, 4:33:32 AM8/13/03
to
Hi…

I’m doing a search page form my work for their library. Since
this is the first time I work with ASP I’m facing some problems.

Each library item has different search data, I was able to build but
I’m stuck at when the user chooses books for e.g it refreshes
the page and the combo box goes to the first item.while I want it to
stay on books.
The second problem is that I need a code for displaying the specific
table chosen by the user from the first combo.

I’ve done it by an if statement but it didn’t work…
This is the code I have come up with:

<html>
<body bgcolor="#FFFFFF" text="#000000" >

<%

Dim strURL
Dim cnnSearch
Dim rstSearch
Dim strDBPath
Dim strSQL
Dim strSearch

strURL = Request.ServerVariables("URL")

strSearch = Request.QueryString("search")
strSearch = Replace(strSearch, "'", "''")
y=request("mymenu")

%>

<b>
<form name="form1" method="get" action="test.asp">
<font color="#32B0AF" size="2">
Search in:
</font>
<select name="mymenu" onchange="document.form1.submit()">
<option value="0" selected>---Select---</option>
<option value="1">Book</option>
<option value="2">Magazine</option>
<option value="3">Legal Gazzete</option>
<option value="4">Science Paper</option>
<option value="5">Video</option>
<option value="6">Clipping</option>
</select>


<% if y>0 then %>
<font color="#32B0AF" size="2">
Search By:
</font>

<%Select Case y
Case "1"
%>
<select name="sub" >
<option value="0" selected>---Select---</option>
<option value="title">Title</option>
<option value="author">Author</option>
<option value="topic">Topic</option>
<option value="keyword">Keyword</option>
</select>

<% Case "2"%>
<select name="sub">
<option value="0" selected>---Select---</option>
<option value="name">Name</option>
<option value="title">Title</option>
</select>

<% Case "3"%>
<select name="sub">
<option value="0" selected>---Select---</option>
<option value="title">Title</option>
</select>

<% Case "4"%>
<select name="sub">
<option value="0" selected>---Select---</option>
<option value="title">Title</option>
<option value="author">Author</option>
</select>

<% Case "5" %>
<select name="sub">
<option value="0" selected>---Select---</option>
<option value="title">Title Keyword</option>
</select>


<% Case "6" %>
<select name="sub">
<option value="0" selected>---Select---</option>
<option value="title">Title Keyword</option>
</select>
<%Case Else

End Select%>

<input type="text" name="search">
<input type="submit" value="Search">

<% end if %>

</p>

<%
If strSearch <> "" Then

strDBPath = Server.MapPath("User Library system.bak")

Set cnnSearch = Server.CreateObject("ADODB.Connection")

cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\Inetpub\wwwroot\User Library
system.bak;" & _
"Jet OLEDB:System
Database=C:\Inetpub\wwwroot\Secured.mdw;", _
"staff", "envr"

'if(y=1) then
strSQL = "SELECT bookid, title, topic " _
& "FROM books " _
& "WHERE title LIKE '%" & Replace(strSearch, "'", "''") & "%' order
by bookid ;"
'else if (y=2) then
'strSQL = "SELECT magazineid,name,title " _
'& "FROM Magazine " _
'& "WHERE name LIKE '%" & Replace(strSearch, "'", "''") & "%'
order by magazineid ;"
'end if

Set rstSearch = cnnSearch.Execute(strSQL)
%>

<table border="1">
<TR><TH>Book Id</th> <th>Title</th> <th>Topic</th></tr>
<%
Do While Not rstSearch.EOF
%>
<tr>
<td><%= rstSearch.Fields("bookid").Value %> </td>
<td><%= rstSearch.Fields("title").Value %> </td>
<td><%= rstSearch.Fields("topic").Value %> </td>
</tr>
<%
rstSearch.MoveNext
Loop
%>
</table>
<%
rstSearch.Close
Set rstSearch = Nothing
cnnSearch.Close
Set cnnSearch = Nothing
End If
%>
</body>
</html>


Thanxxxxx for ur help

William Tasso

unread,
Aug 13, 2003, 4:56:51 AM8/13/03
to
amoona wrote:
> ...

> Each library item has different search data, I was able to build but
> I&#8217;m stuck at when the user chooses books for e.g it refreshes
> the page and the combo box goes to the first item.while I want it to
> stay on books.

Your script needs to capture the selected option and insert
selected="selected" when rewriting the page.


> The second problem is that I need a code for displaying the specific
> table chosen by the user from the first combo.
>
> I&#8217;ve done it by an if statement but it didn&#8217;t work&#8230;

> ...

What did it do instead of what you wanted?
Was there an error message?
Is there a URL?


--
William Tasso - http://WilliamTasso.com


amoona m

unread,
Aug 13, 2003, 10:33:13 AM8/13/03
to

hi

william thanxx 4 replying..

you told i have to capture the selected option.. how do i do that?? (ur
talking to someone who knows nothing in asp)

the second problem without the if statement it will always go to the
book table.if i put the if statement it doen't go in it bcoz it always
takes the value of y as 0.

so its says that there is an error at this line:
Set rstSearch = cnnSearch.Execute(strSQL)
bcoz there is no object.

hope u can help me in this


thanxx alot

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

0 new messages