I have a problem with ADO.
I have made a function that searches in a database for some specific keywords.
The problem I have is that wen i copy the SQL query to the database that the ASP page opens, it works fine, it shows the results, but when the ASP page sends the Query string to the database, it returns no values.
the code is a bit long, but I include all of it, to make sure I dont forget anything...
In case you need all of it to help let me know and I will E-mail the database and the asp pages.
There are 2 ways of searching either by keywords or the document ID directly.
The Document ID works but not the keywords.
Any help would be higly appreciated.
Kind regards,
Brian Levinsen
Eldaria
That was my 25cent** of opinion.
** Inclusive Intrest, tax on interest, Genral tax, Enviromental tax, Tax, and tax on intrest, tax on fees, tax on tax, and other Various taxes and fees.
I have made a function that searches in a database for some specific keywords.
The problem I have is that wen i copy the SQL query to the database that the ASP page opens, it works fine, it shows the results, but when the ASP page sends the Query string to the database, it returns no values.
the code is a bit long, but I include all of it, to make sure I dont forget anything...
In case you need all of it to help let me know and I will E-mail the database and the asp pages.
There are 2 ways of searching either by keywords or the document ID directly.
The Document ID works but not the keywords.
Any help would be higly appreciated.
Kind regards,
Brian Levinsen
Code:
<html>
<link rel="stylesheet" type="text/css" href="style.css" />
<head>
<%
dim ftx
dim did
dim cat
dim lang
dim critstr
Dim critstrs()
dim critstrnr
Dim pos
dim prepos
ftx=request.querystring("fullsearch")
did=request.querystring("docid")
cat=request.querystring("Category")
lang=request.querystring("Language")
critstrnr = 0
sub ShowResults()
set conn=Server.CreateObject("ADODB.Connection")
Constr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath("kb.mdb")
conn.Open Constr
set rs=Server.CreateObject("ADODB.recordset")
response.write(critstr)
rs.open critstr, conn
if rs.eof then
response.write("No entries found, please go <a class='two' href='javascript:history.go(-1)'>back</a> and modify your criteria.")
else
end if
end sub
%>
<%
sub buildcrit(crittype)
select case crittype
case "full"
critstr="SELECT tbl_Documents.DocID, tbl_Documents.DateCreated, tbl_Documents.Title, tbl_Documents.Keywords FROM tbl_Documents WHERE (("
pos = 1
prepos = 1
Do Until pos = 0
redim preserve critstrs(critstrnr)
prepos = pos
pos = InStr(prepos + 1, ftx, " ")
If pos = 0 Then
critstrs(critstrnr) = Right(ftx, Len(ftx) - prepos + 1)
Else
critstrs(critstrnr) = Mid(ftx, prepos, pos - prepos)
pos = pos + 1
critstrnr = critstrnr + 1
End If
Loop
for Abe = 0 to critstrnr
critstr = critstr & "(tbl_Documents.Title) Like '*" & critstrs(abe) & "*' And "
next
critstr = left(critstr,len(critstr)-5)
critstr = critstr & ") AND ((tbl_Documents.CategoryID) Like '" & cat & "') AND ((tbl_Documents.LanguageID) Like '" & lang & "')"
critstr = critstr & ") OR (("
for Abe = 0 to critstrnr
critstr = critstr & "(tbl_Documents.Keywords) Like '*" & critstrs(abe) & "*' And "
next
critstr = left(critstr,len(critstr)-5)
critstr = critstr & ") AND ((tbl_Documents.CategoryID) Like '" & cat & "') AND ((tbl_Documents.LanguageID) Like '" & lang & "')"
critstr = critstr & ") OR (("
critstr = critstr & "(tbl_Documents.CategoryID) Like '" & cat & "') AND ((tbl_Documents.LanguageID) Like '" & lang & "') AND ("
for Abe = 0 to critstrnr
critstr = critstr & "(tbl_Documents.Document) Like '*" & critstrs(abe) & "*' And "
next
critstr = left(critstr,len(critstr)-5)
critstr = critstr & "))"
case "DocID"
critstr="SELECT DocID, DateCreated, Title, Keywords FROM tbl_Documents WHERE (((tbl_Documents.DocID) = " & did & "))"
end select
end sub
%>
</head>
<body>
<%
select case ftx
case ""
Select case did
case ""
response.write("<h4>No Query Entered, Please go <a class='two' href='javascript:history.go(-1)'>back</a> and enter a search criteria</h4>")
case else
call BuildCrit("DocID")
call ShowResults()
end select
case else
call BuildCrit("full")
call ShowResults()
end select
%>
</body>
</html>
That was my 25cent** of opinion.
** Inclusive Intrest, tax on interest, Genral tax, Enviromental tax, Tax, and tax on intrest, tax on fees, tax on tax, and other Various taxes and fees.