Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO query works in MS Access but not in ASP

Status
Not open for further replies.

Eldaria

Programmer
Sep 20, 2001
123
NL
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


Code:
<html>
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;style.css&quot; />
<head>
<%
dim ftx
dim did
dim cat
dim lang
dim critstr
Dim critstrs()
dim critstrnr
Dim pos
dim prepos
ftx=request.querystring(&quot;fullsearch&quot;)
did=request.querystring(&quot;docid&quot;)
cat=request.querystring(&quot;Category&quot;)
lang=request.querystring(&quot;Language&quot;)
critstrnr = 0

sub ShowResults()

set conn=Server.CreateObject(&quot;ADODB.Connection&quot;)
Constr=&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=&quot; & server.mappath(&quot;kb.mdb&quot;)
conn.Open Constr
set rs=Server.CreateObject(&quot;ADODB.recordset&quot;)
response.write(critstr)

rs.open critstr, conn

if rs.eof then
	response.write(&quot;No entries found, please go <a class='two' href='javascript:history.go(-1)'>back</a> and modify your criteria.&quot;)
else

end if

end sub

%>
<%
sub buildcrit(crittype)
	select case crittype
		case &quot;full&quot;
			critstr=&quot;SELECT tbl_Documents.DocID, tbl_Documents.DateCreated, tbl_Documents.Title, tbl_Documents.Keywords FROM tbl_Documents WHERE ((&quot;
			pos = 1
			prepos = 1
			Do Until pos = 0
				redim preserve critstrs(critstrnr)
				prepos = pos
				pos = InStr(prepos + 1, ftx, &quot; &quot;)
				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 & &quot;(tbl_Documents.Title) Like '*&quot; & critstrs(abe) & &quot;*' And &quot;
			next
			critstr = left(critstr,len(critstr)-5)
			critstr = critstr & &quot;) AND ((tbl_Documents.CategoryID) Like '&quot; & cat & &quot;') AND ((tbl_Documents.LanguageID) Like '&quot; & lang & &quot;')&quot;
			critstr = critstr & &quot;) OR ((&quot;
			for Abe = 0 to critstrnr
				critstr = critstr & &quot;(tbl_Documents.Keywords) Like '*&quot; & critstrs(abe) & &quot;*' And &quot;
			next
			critstr = left(critstr,len(critstr)-5)
			critstr = critstr & &quot;) AND ((tbl_Documents.CategoryID) Like '&quot; & cat & &quot;') AND ((tbl_Documents.LanguageID) Like '&quot; & lang & &quot;')&quot;
			critstr = critstr & &quot;) OR ((&quot;
			critstr = critstr & &quot;(tbl_Documents.CategoryID) Like '&quot; & cat & &quot;') AND ((tbl_Documents.LanguageID) Like '&quot; & lang & &quot;') AND (&quot;
			for Abe = 0 to critstrnr
				critstr = critstr & &quot;(tbl_Documents.Document) Like '*&quot; & critstrs(abe) & &quot;*' And &quot;
			next
			critstr = left(critstr,len(critstr)-5)
			critstr = critstr & &quot;))&quot;
		case &quot;DocID&quot;
			critstr=&quot;SELECT DocID, DateCreated, Title, Keywords FROM tbl_Documents WHERE (((tbl_Documents.DocID) = &quot; & did & &quot;))&quot;
	end select
end sub
%>
</head>
<body>
<%
select case ftx
	case &quot;&quot;
		Select case did
			case &quot;&quot;
				response.write(&quot;<h4>No Query Entered, Please go <a class='two' href='javascript:history.go(-1)'>back</a> and enter a search criteria</h4>&quot;)
			case else
				call BuildCrit(&quot;DocID&quot;)
				call ShowResults()
		end select
	case else
		call BuildCrit(&quot;full&quot;)
		call ShowResults()
end select

%>



</body>
</html>
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.
 
Permissions?

Well I don't belive it is that, because of 2 reasons.
1: It is an Access Database, not SQL database.
2: The other query works, but uses the same connection.

But I really can't get anywhere here? is there really no one out there who had this or know what goes wrong?

Brian.
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top