ASP数据库链接错误,新手上路请大侠指教。 15
提示数据库错误!数据库链接出错,请检查conn语句设置!请问在这里怎么设置以下是错误源代码<!--#includefile="inc/CheckSql.asp"--><%...
提示数据库错误!数据库链接出错,请检查conn语句设置!请问在这里怎么设置
以下是错误源代码
<!--#include file="inc/CheckSql.asp"-->
<%
On Error Resume Next
Dim conn,connstr,db
db = "/my_data_xr/#datalinfeng.mdb"
Set conn = server.CreateObject("ADODB.CONNECTION")
connstr = "Driver={Microsoft Access Driver (/my_data_xr/#datalinfeng.mdb)}; DBQ=" & server.mappath(db)
conn.open connstr
If Err.number <> 0 Then
response.write("数据库链接出错,请检查conn语句设置!")
Err.clear
response.end()
End If
Function check_sql(str)
str=Replace(str,"'","")
str=Replace(str,"--","")
str=Replace(str,";","")
str=Replace(str,"%","")
str=Replace(str,"&","")
str=Replace(str,"*","")
str=Replace(str,"#","")
str=Replace(str,"(","")
str=Replace(str,")","")
str=Replace(str,"=","")
check_sql=str
End Function
Function AspHtml(HtmlStr)
Set re = New RegExp
re.Pattern ="<[^>]+>"
re.Global = True
re.IgnoreCase = False
re.MultiLine = True
momo= re.Replace(HtmlStr,"")
AspHtml = replace(momo," ","")
End Function
%> 展开
以下是错误源代码
<!--#include file="inc/CheckSql.asp"-->
<%
On Error Resume Next
Dim conn,connstr,db
db = "/my_data_xr/#datalinfeng.mdb"
Set conn = server.CreateObject("ADODB.CONNECTION")
connstr = "Driver={Microsoft Access Driver (/my_data_xr/#datalinfeng.mdb)}; DBQ=" & server.mappath(db)
conn.open connstr
If Err.number <> 0 Then
response.write("数据库链接出错,请检查conn语句设置!")
Err.clear
response.end()
End If
Function check_sql(str)
str=Replace(str,"'","")
str=Replace(str,"--","")
str=Replace(str,";","")
str=Replace(str,"%","")
str=Replace(str,"&","")
str=Replace(str,"*","")
str=Replace(str,"#","")
str=Replace(str,"(","")
str=Replace(str,")","")
str=Replace(str,"=","")
check_sql=str
End Function
Function AspHtml(HtmlStr)
Set re = New RegExp
re.Pattern ="<[^>]+>"
re.Global = True
re.IgnoreCase = False
re.MultiLine = True
momo= re.Replace(HtmlStr,"")
AspHtml = replace(momo," ","")
End Function
%> 展开
3个回答
展开全部
db = "/my_data_xr/#datalinfeng.mdb"
Set conn = server.CreateObject("ADODB.CONNECTION")
connstr = "Driver={Microsoft Access Driver (/my_data_xr/#datalinfeng.mdb)}; DBQ=" & server.mappath(db)
改成
db = "./my_data_xr/#datalinfeng.mdb"
Set conn = server.CreateObject("ADODB.CONNECTION")
connstr = "Driver={Microsoft Access Driver (./my_data_xr/#datalinfeng.mdb)}; DBQ=" & server.mappath(db)
试下
Set conn = server.CreateObject("ADODB.CONNECTION")
connstr = "Driver={Microsoft Access Driver (/my_data_xr/#datalinfeng.mdb)}; DBQ=" & server.mappath(db)
改成
db = "./my_data_xr/#datalinfeng.mdb"
Set conn = server.CreateObject("ADODB.CONNECTION")
connstr = "Driver={Microsoft Access Driver (./my_data_xr/#datalinfeng.mdb)}; DBQ=" & server.mappath(db)
试下
更多追问追答
追问
不行
追答
db = "/my_data_xr/#datalinfeng.mdb"
Set conn = server.CreateObject("ADODB.CONNECTION")
connstr = "Driver={Microsoft Access Driver (/my_data_xr/#datalinfeng.mdb)}; DBQ=" & server.mappath(db)
改成
db = "my_data_xr/#datalinfeng.mdb"
Set conn = server.CreateObject("ADODB.CONNECTION")
connstr = "Driver={Microsoft Access Driver (my_data_xr/#datalinfeng.mdb)}; DBQ=" & server.mappath(db)
看看 估计路径的问题比较大
展开全部
明显是这里db = "/my_data_xr/#datalinfeng.mdb"
出问题啊,你比较一下这个路径和你打开折文件所在的路径就知道了
出问题啊,你比较一下这个路径和你打开折文件所在的路径就知道了
更多追问追答
追问
就是写的路径与文件的路径一样
追答
你上面的代码所属文件所在的地方是否有my_data_xr/#datalinfeng.mdb这个数据库?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
先确定一下你数据库文件的位置和名称
db = "/my_data_xr/#datalinfeng.mdb"
set conn=Server.CreateObject("ADODB.Connection")
connstr = "provider=microsoft.jet.oledb.4.0;data source="&Server.MapPath(db)
conn.open connstr
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询