註冊 ImageLoader DLL 後,使用 Visual InterDev 1.0 建立 ASP 網頁專案並連接 SQL Server 資料庫。
建立 Web 專案
- 開啟 Visual InterDev,File → New → Web Project Wizard,專案名
ImageLoad。
- 精靈完成後,Workspace 自動產生
Global.asa。
設定資料庫連線 (DSN)
- Project → Add To Project → Data Connection。
- Data Link Properties → Provider 選 Microsoft OLE DB Provider for SQL Server。
- Connection 頁籤:輸入伺服器名稱、登入帳密、選擇資料庫
Grocevb。
- 完成後產生
Grocevb.dsn,雙擊 Global.asa 可見連線字串變數。
初始化 clsImageLoader
在 Global.asa 的 Session_OnStart 加入兩行程式碼,建立 Session 級的 clsImageLoader 物件(列表 C 略)。
建立 ASP 頁面
- File → New → ASP Page,命名
default.asp。
- 撰寫 ADO 連線與呼叫 DLL 方法的程式碼(列表 D 略)。
至此,Web 端可透過 ASP 呼叫 ActiveX DLL,從資料庫取出圖片並暫存為檔案,再由瀏覽器顯示。