|
來源:www.yesky.com 1. 無法正確運行ASP 當我們建立了一個ASP文件,并且符合語法時,通過瀏覽器輸入以下地址,或通過 資源管理器打開瀏覽: c:\inetpub\wwwroot\a.asp 將出現(xiàn)無法運行的錯誤,并提示權(quán)限不對或文件無法訪問,原因是,ASP文件首先 要求站點是具備“執(zhí)行(腳本)”屬性的;然后要求按照URL格式輸入地址,而不 是DOS格式,所以,請改正這兩個錯誤。
2. 程序移動位置后,無法訪問數(shù)據(jù)庫 這種錯誤首先在ODBC,如果ODBC數(shù)據(jù)源設(shè)置正確,那么需要注意ASP中打開數(shù)據(jù)庫 的命令:Conn.Open 的參數(shù)是否正確。如果正確,則需要注意是否使用了global .asa文件,該文件是ASP連接數(shù)據(jù)庫的配置文件,該文件內(nèi)容如下: <SCRIPT LANGUAGE="VBScript" RUNAT="Server"> 'You can add special event handlers in this file that will get run aut omatically 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 appl ication 'Session_OnEnd Runs when a user's session times out or quits your appl ication '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=(loc al);UID=sa;PWD=;APP=Microsoft(R)Developer Studio;WSID=GREGLEAK;DATABAS E=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后一定是數(shù)據(jù)庫服務(wù)器名稱,如果該處不正確,需 要改正。另外是UID和PWD是否正確;還有,如果OPEN命令使用了SESSION,則需要 注意 Session("Customers_RuntimeUserName") = "sa" Session("Customers_RuntimePassword") = "" 是否正確。
3. RUNAT使用問題 在腳本語法中,有RUNAT參數(shù),表示該腳本是運行在服務(wù)器上還是客戶機上。 如果有RUNAT=SERVER則腳本運行在服務(wù)器上,由ASP解釋程序來解釋執(zhí)行,并將結(jié) 果傳遞給WWW服務(wù)器;否則就是運行在客戶機上,由瀏覽器的腳本虛擬機解釋執(zhí)行 ,這時,和一般的腳本沒有區(qū)別。所以,一定要注意ASP語法中的命令,如:REQ UEST,QUERYSTRING,WRITE等命令或?qū)ο蟊仨氃诰邆銻UNAT參數(shù)的腳本運行;而訪 問HTML的FORM對象的腳本一定沒有RUNAT參數(shù),因為HTML的FORM是客戶機方面的對 象,服務(wù)器無法訪問。
4. 無法向SQL SERVER插入日期字段 如果遇到必須使用美國日期格式插入日期的情況,則需要在服務(wù)器的區(qū)域設(shè) 置上設(shè)置中國長日期格式,請?zhí)貏e注意,ASP是在服務(wù)器上運行的,生成的HTML結(jié) 果傳遞給瀏覽器,所以,所有格式設(shè)置必須在服務(wù)器上。
5. 如何向客戶機推送提示信息 如果在服務(wù)器上判斷訪問錯誤,如注冊失敗、無權(quán)操作記錄等需要提示用戶 的信息。這個信息需要推送到客戶機上,并出現(xiàn)提示窗口,這是經(jīng)常遇到的問題 。這個時候,必須使用動態(tài)頁面的方式,因為錯誤是在服務(wù)器上判斷的,而提示 是在瀏覽器上出現(xiàn)的。我們 可以使用下面的ASP來推送錯誤: on error resume next conn=server.createobject("adodb.connection") conn.open "pubs","wlf","" '如果注冊失敗則錯誤數(shù)大于0 if conn.errors.count>0 then ‘以下代碼生成客戶機上的腳本語言,提供給瀏覽器執(zhí)行 response.write "<script language=javascript>" & chr(13) response.write "{" & chr(13) response.write " window.alert("您無權(quán)訪問數(shù)據(jù)庫!")" & chr(13) response.write "}" & chr(13) response.write "</script >" & chr(13) end if
6. 客戶機盡量使用固定IP地址 由于ASP連接數(shù)據(jù)庫是定時的,默認是: Session("Customers_ConnectionTimeout") = 15 Session("Customers_CommandTimeout") = 30 兩個設(shè)置決定的時間,超時后自動斷開連接,所以,當刷新頁面重新執(zhí)行ASP代碼 時,如果IP分配時間不夠(動態(tài)IP分配需要時間,比靜態(tài)長很多。赡軣o法 連接上,則出現(xiàn)錯誤信息,所以盡量用靜態(tài)IP地址。
|