| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 394 人关注过本帖
标题:[求助]我实在是看不出来这个数据库连接那个错了
只看楼主 加入收藏
gxppa2006
Rank: 1
等 级:新手上路
帖 子:178
专家分:0
注 册:2007-2-27
收藏
 问题点数:0 回复次数:3 
[求助]我实在是看不出来这个数据库连接那个错了

<!--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

%>

搜索更多相关主题的帖子: 数据库 
2007-10-15 12:04
yjdgv
Rank: 1
等 级:新手上路
帖 子:73
专家分:0
注 册:2007-8-25
收藏
得分:0 
改为试试<!--#include file="Conn.asp"-->

2007-10-15 13:12
gxppa2006
Rank: 1
等 级:新手上路
帖 子:178
专家分:0
注 册:2007-2-27
收藏
得分:0 
我那是故意注释掉的

临渊羡鱼,不如退而结网!
2007-10-15 14:04
hmhz
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:30
帖 子:1890
专家分:503
注 册:2006-12-17
收藏
得分:0 

你的数据库连接没错,但连接代码位置放错了
[CODE]<%
set conn= Server.CreateObject("ADODB.Connection")
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("oask.mdb")
conn.Open connstr
%>
<%
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 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
%>[/CODE]


[编程论坛] ASP超级群:49158383  敲门暗号:ASP编程
龍艺博客 http://www.
2007-10-15 15:09
快速回复:[求助]我实在是看不出来这个数据库连接那个错了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017946 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved