473,407 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

search library system in asp

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
Jul 19 '05 #1
2 2059
amoona wrote:
...
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.
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’ve done it by an if statement but it didn’t work…
...


What did it do instead of what you wanted?
Was there an error message?
Is there a URL?
--
William Tasso - http://WilliamTasso.com
Jul 19 '05 #2


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!
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: AaronV | last post by:
Hello, I'm a webmaster for a college newspaper and I'm implementing an article search. I'm running PHP with a MySQL database to store the weekly stories. Does anyone know of an article that...
4
by: middletree | last post by:
Intranet tech support system using ASP/VBScript running on W2000 Server, IIS, and using SQL Server 2000. I need to add a search engine. The problem with using a regular SQL query is that if you...
83
by: D. Dante Lorenso | last post by:
Trying to use the 'search' in the docs section of PostgreSQL.org is extremely SLOW. Considering this is a website for a database and databases are supposed to be good for indexing content, I'd...
3
by: RiceGuy | last post by:
Hi! I'm looking for ideas on what would the best approach to design a search system for a RSS feeds. I will have some 50 RSS feeds (all RSS 2.0 compliant) stored locally on the web server. Now I'm...
12
by: Vjay77 | last post by:
Hi, I haven't posted any problem in quite a while now, but I came to the point that I really need to ask for help. I need to create an application which will search through .txt log file and...
3
by: Pieter | last post by:
Hi, I need some search system, that will return me the records with in indicator of probability. This is for a VB.NET 2005 application with a SQL Server 2000 DataBase. I have a table with...
4
by: Frank Potter | last post by:
I want to search something by a key word from inside my py script. The using google idea comes to my mind first because write a search programme from scratch is not so easy. I want to take...
1
by: gihope | last post by:
Hi, I wonder if someone could help me. I'm trying to develop a search algorithm as I need an engine that can determine the shortest route between two locations based on the number of stops. I...
14
by: S | last post by:
Any idea on how I would be able to do a search within C# that does ranges or words For example I want to search for Chicken in the string string s1 = "This is Great Chicken";
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.