凌美钢笔用英雄墨水:ASP问题.见鬼啦!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

来源:百度文库 编辑:神马品牌网 时间:2024/05/03 07:47:15
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>x</TITLE><LINK href="images/style.css"
rel=stylesheet>
<META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK
href="images/w_style.css" type=text/css rel=stylesheet>
<%dim neirong,shi,rs
neirong=replace(request.Form("neirong"),"'","")
shi=replace(request.Form("shi"),"'","")
if shi=1 then%>
<!--#include file="weihai/byshop_conn.asp" -->
<%elseif shi=2 then%>
<!--#include file="qingdao/byshop_conn.asp" -->
<%else%>
<!--#include file="dalian/byshop_conn.asp" -->
<%end if
rs.open "select * from userdata where company like '%"&neirong&"%' or user like '%"&neirong&"%' or name like '%"&neirong&"%' or message like '%"&neirong&"%' order by tuijian desc",conn,1,1
%>
<%if !!这里!rs.eof!这里!! then
response.Write("<script>alert('没有找到相关信息!')</script>")
response.Write("<script>history.go (-1)</script>")
response.End()
end if%>
不管是rs.eof还是not rs.eof 都会提示没有找到。怎么可能呢?!!
提交数据页的代码
<FORM name=addform action=sousuo.asp method=post>
<SELECT
name=shi id="shi">
<option value="1" selected>x1市</option>
<option value="2">x2市</option>
<option value="3">x3市</option>
</SELECT>
        关键字 :   
<label>
<input name="neirong" type="text" id="neirong" size="40"></from>
高手帮忙!!!

把你条件逐渐减少看看效果

shi=cint(replace(request.Form("shi"),"'",""))

或者 if shi = "1" then

改成这样!!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>x</TITLE><LINK href="images/style.css"
rel=stylesheet>
<META http-equiv=Content-Type content="text/html; charset=gb2312"><LINK
href="images/w_style.css" type=text/css rel=stylesheet>
<%dim neirong,shi,rs
neirong=replace(request.Form("neirong"),"'","")
shi=replace(request.Form("shi"),"'","")
if shi="1" then%>
<!--#include file="weihai/byshop_conn.asp" -->
<%elseif shi="2" then%>
<!--#include file="qingdao/byshop_conn.asp" -->
<%else%>
<!--#include file="dalian/byshop_conn.asp" -->
<%end if
rs.open "select * from userdata where company like '%"&neirong&"%' or user like '%"&neirong&"%' or name like '%"&neirong&"%' or message like '%"&neirong&"%' order by tuijian desc",conn,1,1
%>
<%if rs.bof and rs.eof then
response.Write("<script>alert('没有找到相关信息!')</script>")
response.Write("<script>history.go (-1)</script>")
response.End()
end if%>

你的包含文件不能这样选择的,我以前也是这么试的,但是这样包含文件是不可行的。因为包含文件必须是在文件最初读进去的,预先编译,所以不能放在后面。没有conn当然无法打开数据库,又怎么打开表呢?当然找不到啦。我觉得你应该把这些表放一个数据库中,这样的话就一个包含文件,后面的条件选择 表 就简单啦。
我查找的唯一方法是这样用,你看看吧,我还没有试过不知道可以不可以。
根据不同的需求要求include不同的文件
如各个人的不同设置,所以要求能动态include文件。

代码如下:

Function include(filename)
Dim re,content,fso,f,aspStart,aspEnd

set fso=CreateObject("Scripting.FileSystemObject")
set f=fso.OpenTextFile(server.mappath(filename))
content=f.ReadAll
f.close
set f=nothing
set fso=nothing

set re=new RegExp
re.pattern="^\s*="
aspEnd=1
aspStart=inStr(aspEnd,content,"<%")+2
do while aspStart>aspEnd+1
Response.write Mid(content,aspEnd,aspStart-aspEnd-2)
aspEnd=inStr(aspStart,content,"%\>")+2
Execute(re.replace(Mid(content,aspStart,aspEnd-aspStart-2),"Response.Write "))
aspStart=inStr(aspEnd,content,"<%")+2
loop
Response.write Mid(content,aspEnd)
set re=nothing
End Function

使用范例:

include("youinc.asp")