Asp深度揭密(下)

來源:互聯網
上載者:User
四、Asp組件的開發與使用:
1.    組件的特點?
l    優點:
n    調用方便,節省代碼
n    安全性高
n    支援交易處理,多組件聯合
n    運行速度快
n    升級、修改組件不需修改頁面,因此擴充性好
l    缺點:
n    開發及調試困難
2.    如何使用VB開發?
⑴.開啟VB>>New Project>>ActiveX DLL
⑵.修改項目名稱為course

⑶.修改類別模組的名字為conn_db

⑷.Project>> References,引用COM+ Service Type Library和Microsoft Active Server Pages Object Library。
⑸.修改類代碼如下:
'建立資料庫連接並輸出資料庫欄位
Dim Response As Response
Dim Request As Request
Dim Server As Server
Dim Application As Application
Dim Session As Session
    
Private Sub Class_Initialize()
Dim objContext As ObjectContext
Set objContext = GetObjectContext()
Set Response = objContext("Response")
Set Request = objContext("Request")
Set Server = objContext("Server")
Set Application = objContext("Application")
Set Session = objContext("Session")
End Sub
Sub conn_db()
Set conn = CreateObject("adodb.connection")
conn.open "course_dsn", "course_user", "course_password"
Set rs = CreateObject("adodb.recordset")
rs.open "select * from user_info", conn, 1, 1
If rs.recordcount > 0 Then
For i = 1 To rs.recordcount
Response.write "<br>" & rs("user_name") & "<br>"
If rs.EOF Then Exit For
rs.movenext
Next
End If
rs.Close
Set rs = Nothing
conn.Close
Set conn = Nothing
End Sub
⑹.添加一新類cutstr

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.