Asp組件初級入門與精通系列之五

來源:互聯網
上載者:User

經常我們可以看到在串連資料庫,開啟記錄集的時候,如下:

rs.Open strsql, conn,adOpenDynamic ,adLockPessimistic

在鍵入”,”的時候,後面會出現一個遊標類型或者鎖類型列表可以供選擇。

有時候我們為了簡化,直接rs.open strsql,conn,1,3

第一種方法是不是更加專業一些,我們來看看asp中如何?

 

開啟vb6,建立Activex Dll工程。工程名修改為fCom,類名修改為fC5

Option Explicit

‘定義枚舉類型

Public Enum Interfacedig

   icfirst = 1

   icsecond = 2

   icthree = 3

   icfour = 4

   icfive = 5

   icsix = 6

   icserven = 7

   iceight = 8

End Enum

 

'定義函數

Public Function CallDat(ByVal idig As Integer, ByVal ics As Interfacedig) As Variant

CallDat = idig * ics

End Function

 

Ok,一個組件就寫好了,點擊菜單->檔案->產生fCom.dll檔案

確定,在目錄下就會有fCom.dll檔案

 

測試

開啟visual interdev6.0,產生一個asp檔案

 

<%@ Language=VBScript %>

<HTML>

<BODY>

<%

‘定義,還可以把這一部分放到一個檔案中,就像ado的記錄集<!--#include file="adovbs.inc"-->

   const icfirst = 1

   const icsecond = 2

   const icthree = 3

   const icfour = 4

   const icfive = 5

   const icsix = 6

   const icserven = 7

   const iceight = 8

 

set obj=server.CreateObject("fCom.fc5")

‘這裡可以使用iceight或者8,但是前者使代碼具有更好的可讀性

a= obj.CallDat(4,iceight) 

Response.Write a

Response.Write "<br>"

a= obj.CallDat(4,8) 

Response.Write a

%>

<P>&nbsp;</P>

 

</BODY>

</HTML>

 

配置好虛擬目錄,在ie中執行此asp檔案,得到結果如下:

32
32

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.