JANLEE
08-24-2005, 12:19 PM
Hi,
I am having problems to see the results using tha following statement:
<%Do until rs.EOF%>
<!--##################################-->
<%Select Case Ubound(strKeyword)
Case 0%>
<%=response.write (rs.fields("english"))%>
<%=response.write (rs.fields("castilian"))%>
<%Case 1%>
<%=response.write (rs.fields("english"))%>
<%=response.write (rs.fields("french"))%>
<%End Select%>
<%Loop%>
Could you please help me?
Thanks
JL
nikkiH
08-24-2005, 02:30 PM
Ubound is an array function to check subscripts.
What is strKeyword?
Perhaps you wanted Len to get the length of the string?
JANLEE
08-24-2005, 02:46 PM
I did a mistake: It is = <%Select Case strKeyword. no Ubound.
Are 2 files: query.htm and search.asp
The full script (search.asp) is (which not works fine)
<%@ LANGUAGE=VBScript %>
<%
Option Explicit
Response.Buffer = True
Response.Expires = 0
%>
<HTML>
<HEAD>
<TITLE>Test</TITLE>
</HEAD>
<!-- SearchDb.asp-->
<%
' ADO Constants - Don't Change Them
Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adCmdText = &H0001
Const adUseClient = 3
%>
<%
Dim strDB, sSQL
'set conn=server.CreateObject("adodb.connection")
'conn.open "Provider=Microsoft.jet.oledb.4.0;data source="& server.MapPath("lexicum.mdb")
strDB = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("lexicum.mdb")
Dim currentPage
If Len(Request.QueryString("currentPage")) = 0 Then
currentPage = 1
Else
currentPage = CInt(Request.QueryString("currentPage"))
End If
Dim recordsToShow
recordsToShow = 5
' Keyword/s to search
Dim strKeyword
strKeyword = Request.QueryString("look_for")
Dim strlanguage
' strKeyword = split(Trim(Request.QueryString("look_for")), " ")
strlanguage = Request.QueryString("lang")
Server.ScriptTimeout = 6000
Dim struser
struser = Request.QueryString("users")
' Our Connection Object
Dim con
Set con = CreateObject("ADODB.Connection")
con.Open strDB
' Our Recordset Object
Dim rs
Set rs = CreateObject("ADODB.Recordset")
rs.CursorLocation = adUseClient
rs.PageSize = recordsToShow
rs.CacheSize = recordsToShow
Select Case strKeyword
' Select Case UBound(STRkEYWORD)
Case 0 rs.Open "select * from ec where english like '%" & strKeyword &"%' or castilian like '%" & strKeyword & "%'", con, adOpenForwardOnly, adLockReadOnly, adCmdText
Case 1 rs.Open "select * from ef where english like '%" & strKeyword & "%' or french like '%" & strKeyword & "%' order by english desc", con
Case 2 rs.Open "select * from ei where english like '%" & strKeyword & "%' and italian like '%" & strKeyword & "%' order by english desc", con
Case Else rs.Open "select * from ep where english like '%" & strKeyword & "%' and portuguese like '%" & strKeyword & "%' order by english desc", con
End Select
%>
<BODY>
<!-- ##################################-->
<%Do until rs.EOF%>
<!--##################################-->
<%Select Case strKeyword
Case 0%>
<%=response.write (rs("english"))%>
<%=response.write (rs("castilian"))%>
<%Case 1%>
<%=rs("French")%>
<%Case 2%>
<%=rs("Italian")%>
<%Case 3%>
<%=rs("French")%>
<%End Select%>
<%Loop%>
</BODY>
</HTML>
This script is running at: http://www.terminotics.com/query.htm
Thank you for your interest.
JanLee
<!-- query.htm-->
neocool00
08-24-2005, 03:12 PM
Is "Request.QueryString("look_for")" returning a string or an integer? Your sql statements would lead me to believe that it is returning a string, but your select case statement would lead me to believe it's returning an integer. I suspect that it's coming from an input box on a previous screen, in which case you should change your select case statement.
JANLEE
08-24-2005, 03:46 PM
It is the code of query.htm
<html>
<head>
<title>Untitled</title>
</head>
<body>
<form method="get" action="search.asp">
<input type="radio" name="look_for" value="0">English/Castilian<br>
<input type="radio" name="look_for" value="1">English/French<br>
<input type="radio" name="look_for" value="2">English/Italian<br>
<input type="text" name="query" value="">
<input type="submit">
</form>
</body>
</html>
It returns all records, instead the records that matching with input look_for.
Thanks
JanLee
nikkiH
08-24-2005, 07:32 PM
Those are actually strings, not integers.
Change
Case 0
to
Case "0"
and so on.
JANLEE
08-25-2005, 12:15 AM
Ok.
I will close this thread, although I had not solved my problem.
Jan Lee