新微赢技术网

标题: 请高手解决这个连接不上SQL SERVER 2000的问题,困惑我很长时间了 [打印本页]

作者: 蓝天使者    时间: 2010-1-10 07:20
标题: 请高手解决这个连接不上SQL SERVER 2000的问题,困惑我很长时间了
三个文件:
1.oa.reg 确信以下帐户和密码正确
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Kingcome\KCOA]
"DBServerName"="(local)"
"DatabaseName"="LKOA"
"UserName"="sa"
"PassWord"="111111"
"TempPath"="D:\\_tohaiyan\\kcoa\\AtthTemp"
"INSTALLPATH"="D:\\_tohaiyan\\kcoa"
"Version"="V2.1"
"DBPath"="D:\\_tohaiyan\\kcoa\\DB"
"LKOADIR"="D:\\_tohaiyan\\kcoa"

2.global.asa
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=unicode" http-equiv=Content-Type>
<SCRIPT LANGUAGE=VBScript RUNAT="Server">
Sub Application_Onstart
    dim sServer,sUser,sDBName,sPass,sTmpPath,sInstallPath,sVersion
    Dim WshShell
    set WshShell=Server.CreateObject("WScript.Shell")
    sserver=WshShell.RegRead("HKLM\SOFTWARE\Kingcome\KCOA\DBServerName")
    sDBName=WshShell.RegRead("HKLM\SOFTWARE\Kingcome\KCOA\DatabaseName")
    sUser=WshShell.RegRead("HKLM\SOFTWARE\Kingcome\KCOA\UserName")
    sPass=WshShell.RegRead("HKLM\SOFTWARE\Kingcome\KCOA\PassWord")
    sTmpPath=WshShell.RegRead("HKLM\SOFTWARE\Kingcome\KCOA\TempPath")
    sInstallPath=WshShell.RegRead("HKLM\SOFTWARE\Kingcome\KCOA\INSTALLPATH")
    sVersion=WshShell.RegRead("HKLM\SOFTWARE\Kingcome\KCOA\Version")
    if right(sInstallPath,1)="\" then sInstallPath = mid(sInstallPath,1,len(sInstallPath)-1)
    set WshShell = nothing
    if sserver&"" = "" then    sserver="127.0.0.1"
    Application("ConnectString") = _
                "Provider=SQLOLEDB.1;" _
                & "Password=" & sPass & ";" _
                & "Persist Security Info=True;" _
                & "User ID=" & sUser & ";" _
                & "Initial Catalog=" & sDBName & ";" _
                & "Data Source=" & sServer & ";" _
                & "Connect Timeout=15"
    Application("RecPerPage")    =    15
    Application.Lock
    Application("whoson")=0
    Application.UnLock
    Application("Pub_Gs_ShowStr")    = "公司"
    Application("Pub_Bm_ShowStr")    = "部门"
    Application("Pub_Yg_ShowStr")    = "员工"
    Application("TempPath")    = sTmpPath
    Application("LKOAPath")    = sInstallPath
    Application("LKOAVersion") = sVersion
End sub

Sub Session_Onstart
    Session("uID")=""
    Session("uDeptID")=""
    Session("uName")=""
    Session("uNC")=""
    Session("uDeptName")=""
    Session("uYGBH")=""
    Session("uKL")=""
    Session("bbs_userName")=""
    Session("bbs_userID")=""
    Session("bbs_Dl") = ""
    'session.Timeout=20
End sub

sub session_onend
application.Lock
application("whoson")=application("whoson")-1
if application("whoson")< 1 then
    application("whoson") = 0
end if
application.UnLock
end sub
</SCRIPT>
3.connect.asp  为什么无法连接数据库
<% Response.Buffer = True %>
<%
Dim Conn
    on error resume next
    Set Conn=server.CreateObject("ADODB.CONNECTION")   
     conn.open Application("ConnectString")
    if Err<>0 then
    %>
        <script language="vbscript">
            msgbox "无法连接数据库!",vbCritical,"错误"
        </script>
    <%   
        Response.End
    end if
%>




欢迎光临 新微赢技术网 (http://bbs.weiying.cn/) Powered by Discuz! X3.2