标题:access 数据库链接DNS问题
只看楼主
gzklw
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-1-16
 问题点数:0 回复次数:0 
access 数据库链接DNS问题
最近在ixwebhosting买了一个windows的空间,用的是ACCESS的数据库,我创建了DSN,DSN名称是C283155_fanrengu,我的conn.asp设置如下:

<%
dim conn,connstr,startime,TimesDB,rs,UserAgent
startime=timer()
'数据库类别,1为SQL数据库,0为Access数据库
Const IsSqlDataBase = 0
'数据库名称和路径
TimesDB="data\TimesShop.mdb"

Dim Fy_Url,Fy_a,Fy_x,Fy_Cs(),Fy_Cl,Fy_Ts,Fy_Zx
Fy_Cl = 1        '处理方式:1=提示信息,2=转向页面,3=先提示再转向
Fy_Zx = "index.Asp"    '出错时转向的页面
On Error Resume Next
Fy_Url=Request.ServerVariables("QUERY_STRING")
Fy_a=split(Fy_Url,"&amp;")
redim Fy_Cs(ubound(Fy_a))
On Error Resume Next
for Fy_x=0 to ubound(Fy_a)
Fy_Cs(Fy_x) = left(Fy_a(Fy_x),instr(Fy_a(Fy_x),"=")-1)
Next
For Fy_x=0 to ubound(Fy_Cs)
If Fy_Cs(Fy_x)<>"" Then
If Instr(LCase(Request(Fy_Cs(Fy_x))),"'")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"%20and%20")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"%20select%20")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"%20update%20")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"%20chr")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"delete%20from")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),";")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"%20insert%20")<>0 or Instr(LCase(Request(Fy_Cs(Fy_x))),"%20mid")<>0 Or Instr(LCase(Request(Fy_Cs(Fy_x))),"master.")<>0 Then
Select Case Fy_Cl
  Case "1"
Response.Write "<Script Language=JavaScript>alert('                   出现错误!参数 "&amp;Fy_Cs(Fy_x)&amp;" 的值中包含非法字符串!\n\n  请不要在参数中出现:;,and,select,update,insert,delete,chr 等非法字符!');window.close();</Script>"
  Case "2"
Response.Write "<Script Language=JavaScript>location.href='"&amp;Fy_Zx&amp;"'</Script>"
  Case "3"
Response.Write "<Script Language=JavaScript>alert('                   出现错误!参数 "&amp;Fy_Cs(Fy_x)&amp;"的值中包含非法字符串!\n\n  请不要在参数中出现:;,and,select,update,insert,delete,chr 等非法字符!');location.href='"&amp;Fy_Zx&amp;"';</Script>"
End Select
Response.End
End If
End If
Next

ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(""&TimesDB&"")
On Error Resume Next
    Set conn = Server.CreateObject("ADODB.Connection")
    conn.open connstr
    If Err Then
        err.Clear
        Set Conn = Nothing
        Response.Write "数据库连接出错,请检查Conn.asp中的数据库指向。"'
        Response.End
    End If
   
Dim strTitle,LngDiscount,strUserName,LngUserID,LngGrpID,LngDeposit,rsVip,strUserEmail
LngDiscount = 1
LngUserID = 0
LngDeposit = 0
strUserName = "非会员"
strTitle = "非会员"
if HTMLEncode(Request.Cookies("timesshop")("username")) <> "" then
set rsVip=server.CreateObject("adodb.recordset")
rsVip.open "select [User].GrpID,[User].UserID,[User].Score,[User].UserEmail,[User].Deposit,[User].UserName,TimesGrp.GrpName,TimesGrp.Stars from [User] Inner Join TimesGrp On [User].GrpID = TimesGrp.GrpID where username='"&amp;HTMLEncode(Request.Cookies("timesshop")("username"))&amp;"' ",conn,1,1
strTitle = rsVip("GrpName")
LngDiscount = rsVip("Stars")
LngGrpID = Clng(rsVip("GrpID"))
strUserName = rsVip("UserName")
LngUserID = Clng(rsVip("UserID"))
LngScore = Clng(rsVip("Score"))
LngDeposit = rsVip("Deposit")
strUserEmail = rsVip("UserEmail")
rsVip.close
set rsVip=nothing
End If

Select Case LngGrpID
    Case ""
        LstPrice = "Price1"
    Case 4
        LstPrice = "Price2"
    Case 30
        LstPrice = "Price3"
    Case 31
        LstPrice = "Price4"
    Case 32
        LstPrice = "Price5"
End Select


'//增添规则,非会员价与会员价相同
LstPrice = "Price2"

dim css_new_moneyName
css_new_moneyName = "先汇款价格"



'/////////////从特价网过来的用户,记录cookies
dim css_tjw_source,css_tjw_uid
css_tjw_source = lcase(request.querystring("source"))
css_tjw_uid = request.querystring("uid")
if css_tjw_source = "tejiawang" then
    if isnumeric(css_tjw_uid) and css_tjw_uid <> "" then
        css_tjw_uid = abs(fix(css_tjw_uid))
        
        response.cookies("tjw")("uid") = css_tjw_uid
    end if
end if
'///////////////////////////////
%>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="include/css.css" rel="stylesheet" type="text/css">

我不懂技术,请问哪位朋友知道应该如何修改?我的数据库路径是“/c283155/”,我用用相对路径来设置数据库来源。
不知道是否需要DSN的用户名和密码?到底该如何修改上面的代码才能使CONN.asp指向数据库,现在老是提示“数据库连接出错,请检查Conn.asp中的数据库指向。”
搜索更多相关主题的帖子: 链接 access DNS 数据库 
2010-01-16 14:28



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-295858-1-1.html




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

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