标题:各位高手能否帮我看一下这个conn.ASP的设置哪里出问题,数据库连接不上
只看楼主
xianjie84
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-5-23
结帖率:0
已结贴  问题点数:20 回复次数:1 
各位高手能否帮我看一下这个conn.ASP的设置哪里出问题,数据库连接不上
各位高手能否帮我看一下这个conn.ASP的设置哪里出问题,数据库连接不上
原文内容:
<%session.Timeout=180%>
<%
Dim scriptName
scriptName=Request.ServerVariables("script_name")
i = instrRev(scriptname,"/")
scriptname = ucase(right(scriptname,len(scriptname)-i))
'Response.Write scriptname
''''''''''''''''''''''''''''''''''''''''''''''''''''''以上四行语句得到本页面的文件名称,后边要进行文件名称比较

Dim Conn
Dim DBFileObject,DBFile
Dim strTmp,strServer,strDB,strUid,strPwd,arrTmp
   
strTmp = ""
strServer = ""
strDB = ""
strUid = ""
strPwd = ""
set InfoEncrypt=server.CreateObject("Infoencrypt.encrypt")
'Response.Write infoencrypt.encode("yxz")& "<br>"
'Response.Write infoencrypt.encode("scm")& "<br>"
'Response.Write infoencrypt.encode("idudba")& "<br>"
'Response.Write infoencrypt.encode("iloveidu")& "<br>"
'Response.Write infoencrypt.encode("yxz数据库")& "<br>"
'Response.End
Set DBFileObject = Server.CreateObject("Scripting.FileSystemObject")
   
Dim strFilePath
strFilePath = Trim(Request.ServerVariables("APPL_PHYSICAL_PATH"))
strFilePath = strFilePath + "ConfigSys\DBServerInfo.dat"   
Set DBFile = DBFileObject.OpenTextFile(strFilePath)
   
Count=0
Do while not DBFile.AtEndOfStream
    strTmp = DBFile.ReadLine
    arrTmp = split(strTmp,"и",-1)
    if InfoEncrypt.decode(trim(arrTmp(4)))=Request.Form("strAccount") then
        strServer = InfoEncrypt.decode(trim(arrTmp(0)))
        strDB =InfoEncrypt.decode(trim(arrTmp(1)))
        strUid =InfoEncrypt.decode(trim(arrTmp(2)))
        strPwd =InfoEncrypt.decode(trim(arrTmp(3)))
        session("strServer") = strServer
    session("strDB") =strDB
        session("strUid") =strUid
        session("strPwd") =strPwd
        session("strAccount")=Request.Form("strAccount")
        exit Do
    End if
    Count=Count+1
loop
DBFile.Close
'Response.Write strServer& "<br>" & strDB &"<br>"& strUid
'''''''''''''''''''''''''''''''''''''''''''''通过上页的表单值确定打开哪个帐套,并得到打开数据库连接的参数
'If IsObject(Session("SCMConn")) and Not IsNull(Session("SCMConn")) and scriptName<>"LOGIN.ASP" and session("UserID")<>"" Then
If IsObject(Session("SCMConn")) and Not IsNull(Session("SCMConn"))  and scriptName<>"LOGIN.ASP"  Then
    Set Conn = Session("SCMConn")
Else
    If strServer <> "" and strDB <> "" and strUid <> "" Then
    'On Error Resume Next
       Set Conn=Server.CreateObject ("adodb.connection")
        Conn.Open "driver={sql server};server="&58.61.157.153&";uid="&sq_xianjie84&";pwd="&ppij840314&";database="&sq_xianjie84        
        If Err.number>0    Then
            Response.Write "数据库服务器端连接错误,请您点击<a href='mailto:master@'>这里</a>用邮件与易读网管理员联系。谢谢!</p>"
            Response.End
        Else
            Set Session("SCMConn") = Conn
        End If
    Else
        'Response.Write "<br><br><div align=center><h1>数据库服务器配置有错误,请重新配置!</h1></div>"
        'Response.End
    End If
End If

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''以下为 DataAccess组件
'If IsObject(Session("SCMDataAccess")) and  Not IsNull(Session("SCMDataAccess")) and scriptName<>"LOGIN.ASP"  and session("UserID")<>""  Then
If IsObject(Session("SCMDataAccess")) and  Not IsNull(Session("SCMDataAccess")) and scriptName<>"LOGIN.ASP"   Then
    Set DataAccess = Session("SCMDataAccess")
Else
    If strServer <> "" and strDB <> "" and strUid <> "" Then
        dim DataAccess
        Set DataAccess=server.CreateObject("DataAccess.Access")
        DataAccess.Server =strServer
        DataAccess.UserName=strUid
        DataAccess.Password=strPwd
        DataAccess.DB =strDB
        DataAccess.OpenConn()
   
        If Err.number>0    Then
            Response.Write "数据库服务器端连接错误,请您点击<a href='mailto:master@'>这里</a>用邮件与易读网管理员联系。谢谢!</p>"
            Response.End
        Else
            Set Session("SCMDataAccess") = DataAccess
        End If
    Else
        'Response.Write "<br><br><div align=center><h1>数据库服务器配置有错误,请重新配置!</h1></div>"
        'Response.End
    End If
End If
'Response.Write strDB&"<br>asdf<br>"
'Response.Write strUid
'Response.End

%>
搜索更多相关主题的帖子: 数据库 conn ASP 
2010-05-23 21:19
gupiao175
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:40
帖 子:1787
专家分:7527
注 册:2007-6-27
得分:20 
你的问题是连不上,那么错误提示呢?
把这种Err.number>0 错误处理语句去掉!让ASP自己分析错误然后提示!

Q:1428196631,百度:开发地 即可找到我,有事请留言!
2010-05-24 13:16



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




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

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