设为首页收藏本站

新微赢技术网

 找回密码
 注册
搜索
热搜: 回贴
查看: 42|回复: 2
打印 上一主题 下一主题

[求助]我实在是看不出来这个数据库连接那个错了

[复制链接]
跳转到指定楼层
1#
发表于 2010-1-8 22:57:38 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
<!--3#include file="Conn.asp"--> <!-- 数据库链接 -->
<%
dim keyword,keywordList,path,sql,forbidWord '定义变量
sql="" 'SQL语句
keyword=Request.QueryString("context") '读取传来的context
keyword=ltrim(rtrim(keyword)) '取消前后空格
if keyword="" then '如果关键词为空
response.Write"<script>windows.alert("请输入关键词!");history.back();</script>" '则提示输入关键词..返回上一页
else'如不为空
forbidWord=Array("~","!","@","#","$","%","^","&","*","(",")","_","+","=","`","[","]","{","}",";",":","""","'",",","<",">",".","/","\","|","?","_","about","1","2","3","4","5","6","7","8","9","0","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","after","all","also","an","and","another","any","are","as","at","be","because","been","before","being","between","both","but","by","came","can","come","could","did","do","each","for","from","get","got","had","has","have","he","her","here","him","himself","his","how","if","in","into","is","it","like","make","many","me","might","more","most","much","must","my","never","now","of","on","only","or","other","our","out","over","said","same","see","should","since","some","still","such","take","than","that","the","their","them","then","there","these","they","this","those","through","to","too","under","up","very","was","way","we","well","were","what","where","which","while","who","with","would","you","your","的","一","不","在","人","有","是","为","以","于","上","他","而","后","之","来","及","了","因","下","可","到","由","这","与","也","此","但","并","个","其","已","无","小","我","们","起","最","再","今","去","好","只","又","或","很","亦","某","把","那","你","乃","它") '取消一般语气词
keyword = Left(keyword,100)
For i=0 To Ubound(forbidWord)
keyword=Replace(keyword,forbidWord(i)," ")
Next
keyword = Replace(keyword,"!"," ")
keyword = Replace(keyword,"]"," ")
keyword = Replace(keyword,"["," ")
keyword = Replace(keyword,")"," ")
keyword = Replace(keyword,"("," ")
keyword = Replace(keyword," "," ")
keyword = Replace(keyword,"-"," ")
keyword = Replace(keyword,"/"," ")
keyword = Replace(keyword,"+"," ")
keyword = Replace(keyword,"="," ")
keyword = Replace(keyword,","," ")
keyword = Replace(keyword,"'"," ")
keywordlist=split(keyword," ") '将用户输入的关键词分成多个保存在数组keywordlist中
End if
for i=0 to ubound(keywordlist)'得到数组的最大下标
keywordlist(i) = trim(keywordlist(i))'去除空格
sql=sql &"title like'%" & keywordlist(i) & "%'or"'数据表web里的titel列的值中包含关键词keywordlist(i)
sql=sql &"content like'%" & keywordlist(i) & "%'or"
next
sql=left(sql,(len(sql)-3))'获取字符串长度,去掉字符串最后三个字符
sql="select * from askQuestion where"&sql
'以下是数据库测试
set conn= Server.CreateObject("ADODB.Connection")
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("oask.mdb")
conn.Open connstr
Set rs=server.CreateObject("ADODB.Recordset")
rs.Open sql,1,3
If Not rs.Bof And Not rs.Eof Then
%>
<table>
<tr>
<td><%=rs("title")%></td>
</tr>
</table>
<%
rs.movenext
end if
rs.close
set rs=nothing
%>
2#
发表于 2010-1-9 20:05:04 | 只看该作者
写得好啊 估计有马甲
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

申请友链|小黑屋|最新主题|手机版|新微赢技术网 ( 苏ICP备08020429号 )  

GMT+8, 2024-11-18 20:32 , Processed in 0.105804 second(s), 9 queries , Gzip On, Memcache On.

Powered by xuexi

© 2001-2013 HaiAn.Com.Cn Inc. 寰耽

快速回复 返回顶部 返回列表