基於ASP技術開發Internet/Intranet上的MIS系統是非常方便的,首先是它借用了ADO技術和概念,同時通過ODBC訪問資料庫,達到了充分的靈活性和多平台性,另外,由於ASP利用VBS和JS指令碼語言,也保證大多數開發人員很快進入開發過程,減少了學習的過程。
但是,由於ASP是基於Internet/Intranet方式的,它和傳統的C/S結構畢竟有所不同,這樣在開發中也要注意一些細節問題。本文講述常見的一些問題,並給出解決方案。
問題描述
A. 無法正確運行ASP
當我們建立了一個ASP檔案,並且符合文法時,通過瀏覽器輸入以下地址,或通過資源管理員開啟瀏覽:
c:inetpubwwwroota.asp
將出現無法啟動並執行錯誤,並提示許可權不對或檔案無法訪問,原因是,ASP檔案首先要求網站是具備“執行(指令碼)”屬性的;然後要求按照URL格式輸入地址,而不是DOS格式,所以,請改正這兩個錯誤。
B. 程式移動位置後,無法訪問資料庫
這種錯誤首先在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==