Using VB ASP Access.

Here's the error I'm getting:

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch
/RP_Ref_Guide/RP_search_results.asp, line 23


Browser Type:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)

Page:
POST 109 bytes to /RP_Ref_Guide/RP_search_results.asp

POST Data:
Partner_Name=Agilsys+Hospitality+Systems&Relationship=&Industry=&Partner_Manager=&Territory=&RP_Search=Search

Here's the code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/RP_DB.asp" -->
<%
rp_name = Request.Form("Partner_Name")
rp_rel = Request.Form("Relationship")
rp_ind = Request.Form("Industry")
rp_mgr = Request.Form("Partner_Manager")
rp_ter = Request.Form("Territory")

Dim results1
Dim results1_cmd
Dim results1_numRows

Set results1_cmd = Server.CreateObject ("ADODB.Command")
results1_cmd.ActiveConnection = MM_RP_DB_STRING
results1_cmd.CommandText = "SELECT Partner_company, Terr_Name, partnerManager_name, relationship_name, industry_name FROM RP_Search_results" 
results1_cmd.Prepared = true
			
Set results1 = results1_cmd.Execute
results1_numRows = 0
%>
<% 
======>	IF rp_name <> "" THEN results1 = results1 &_ <=====
		" WHERE Partner_company = '" & rp_name & "'"
	IF rp_mgr <> "" AND rp_name = "" THEN results1 = results1 &_
		" WHERE partnerManager_name = '" & rp_mgr & "'"
	IF rp_mgr <> "" AND rp_name <> "" THEN results1 = results1 &_
		" AND partnerManager_name = '" & rp_mgr & "'"
	IF rp_ter <> "" AND (rp_mgr = "" AND rp_name = "") THEN results1 = results1 &_
		" WHERE Terr_Name = '" & rp_ter & "'"
	IF rp_ter <> "" AND (rp_mgr <> "" OR rp_name <> "") THEN results1 = results1 &_
		" AND Terr_Name = '" & rp_ter & "'"
	IF rp_rel <> "" AND (rp_mgr = "" AND rp_name = "" AND rp_ter = "" ) THEN results1 = results1 &_
		" WHERE relationship_name = '" & rp_rel & "'"
	IF rp_rel <> "" AND (rp_mgr <> "" OR rp_name <> "" OR rp_ter <> "") THEN results1 = results1 &_
		" AND relationship_name = '" & rp_rel & "'"
	IF rp_ind <> "" AND (rp_mgr = "" AND rp_name = "" AND rp_ter = "" AND rp_rel = "" ) THEN results1 = results1 &_
		" WHERE industry_name = '" & rp_ind & "'"
	IF rp_ind <> "" AND (rp_mgr <> "" OR rp_name <> "" OR rp_ter <> "" OR rp_rel <> "") THEN results1 = results1 &_
		" AND industry_name = '" & rp_ind & "'"
response.Write(results1)
response.End(results1)
%>

Look at line 19 in your code. Set results1 = results1_cmd.Execute You have initialized results1 as an ADODB.Recordset object.

You problem lies in that you are trying to append a string to the recordset object. IF rp_mgr <> "" AND rp_name = "" THEN results1 = results1 &_ ... Instead, you need to be appending to results1_cmd.CommandText. Better yet, define a variable to hold the string, append to it and then set the results1_cmd.CommandText = variable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.