当前位置:编程学习 > asp >>

程序移动位置后,无法访问数据库

答案:

这种错误首先在ODBC,如果ODBC数据源设置正确,那么需要注意ASP中打开数据库的命令:Conn.Open 的参数是否正确。如果正确,则需要注意是否使用了global.asa文件,该文件是ASP连接数据库的配置文件,该文件内容如下:
<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
'You can add special event handlers in this file that will get run automatically when special Active Server Pages events
'occur. To create these handlers, just create a subroutine with a name from the list below that corresponds to the event
'you want to use. For example, to create an event handler for Session_OnStart, you would put the following code into this
'file (without the comments):
'EventName Description
'Session_OnStart Runs the first time a user runs any page in your application
'Session_OnEnd Runs when a user's session times out or quits your application
'Application_OnStart Runs once when the first page of your application is run for the first time by any user
'Application_OnEnd Runs once when the web server shuts down

</SCRIPT>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Session_OnStart
'==Visual InterDev Generated - DataConnection startspan==
'--Project Data Connection
Session("Customers_ConnectionString")="DRIVER={SQL Server};SERVER=(local);UID=sa;PWD=;APP=Microsoft(R)Developer Studio;WSID=GREGLEAK;DATABASE=Customers"
Session("Customers_ConnectionTimeout") = 15
Session("Customers_CommandTimeout") = 30
Session("Customers_RuntimeUserName") = "sa"
Session("Customers_RuntimePassword") = ""
'==Visual InterDev Generated - DataConnection endspan==
End Sub
</SCRIPT>
要注意其中的DSN,其中SERVER后一定是数据库服务器名称,如果该处不正确,需要改正。另外是UID和PWD是否正确;还有,如果OPEN命令使用了SESSION,则需要注意
Session("Customers_RuntimeUserName") = "sa"
Session("Customers_RuntimePassword") = ""
是否正确。

上一个:ASP处理程序时显示进度
下一个:asp学习入门

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,