首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式碼之家 >> 數據庫知識 >  >> SQL Server 資料庫 >> 關於SqlServer

用 SQL Server 為 Web 瀏覽器提供圖像(四):Web 專案與資料庫連線建立

     編輯:關於SqlServer

註冊 ImageLoader DLL 後,使用 Visual InterDev 1.0 建立 ASP 網頁專案並連接 SQL Server 資料庫。

建立 Web 專案

  1. 開啟 Visual InterDev,File → New → Web Project Wizard,專案名 ImageLoad。
  2. 精靈完成後,Workspace 自動產生 Global.asa。

設定資料庫連線 (DSN)

  1. Project → Add To Project → Data Connection。
  2. Data Link Properties → Provider 選 Microsoft OLE DB Provider for SQL Server。
  3. Connection 頁籤:輸入伺服器名稱、登入帳密、選擇資料庫 Grocevb。
  4. 完成後產生 Grocevb.dsn,雙擊 Global.asa 可見連線字串變數。

初始化 clsImageLoader

在 Global.asa 的 Session_OnStart 加入兩行程式碼,建立 Session 級的 clsImageLoader 物件(列表 C 略)。

建立 ASP 頁面

  1. File → New → ASP Page,命名 default.asp。
  2. 撰寫 ADO 連線與呼叫 DLL 方法的程式碼(列表 D 略)。

至此,Web 端可透過 ASP 呼叫 ActiveX DLL,從資料庫取出圖片並暫存為檔案,再由瀏覽器顯示。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved