首先,如果只是直接將access數據庫的後綴名改為.asp是無法防止下載的,正確的做法是,建立一個表,為這個表中寫入二進制文件,即OLE對象。具體代碼如下:
<%
Dim DB,RS,SQL
DB = "DB.asp" ’這裡改成你的數據庫,後綴一定要是asp
Set Conn = Server.CreateObject("Adodb.Connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath(db)
Conn.Execute("Create Table NotDownload(NotDown OLEObject)")
Set RS = Server.CreateObject("ADODB.RecordSet")
SQL = "Select * FROM NotDownload"
RS.Open SQL,Conn,1,3
RS.Addnew
RS("NotDown").appendchunk(chrB(Asc("<")) & chrB(Asc("%")))
RS.Update
RS.Close
Set RS = Nothing
Conn.Close
Set Conn = Nothing
Response.Write "數據庫防下載處理完成,請確認您的Access數據庫已經改為ASP後綴"
%>