asp對象化之:資料庫結果集合操作類

來源:互聯網
上載者:User
對象|集合|資料|資料庫 <% 

’************************************************************* 
’轉寄時請保留此聲明資訊,這段聲明不並會影響你的速度! 
’************************************************************* 


’************************************************************* 
’@author:                        麵條 
’@realname:                        徐仁祿 
’@email:                        xurenlu@sohu.com 
’@QQ:                            55547082 
’@Homepage:                        http://www.ksdn.net 
’@著作權申明: 
’            非盈利性質團體或者個人可以免費使用. 
’************************************************************* 


’************************************************************* 
’************************************************************* 
’************************************************************* 
class Rsclass 
    private iRs 
    private isql 
    private iconn 
    private closeConn 
    private openConn 

’************************************************************* 
’        進行初始化,建立iconn和irs對象. 
’************************************************************* 
    Private Sub Class_initialize()  
        set iconn=server.createobject("adodb.connection") 
        set irs=server.createobject("adodb.recordset") 
    End Sub  
     
    public sub connect(connstr) 
        err.clear 
        on error resume next 
        iconn.open connstr 
        if err.number<>0 then response.write "資料聯結出錯了." 
    end sub 
     
    public property let conn(connection) 
        set iconn=connection        ’通過外界傳入一個資料庫聯結. 
    end property 
     
     
     
    Private Sub Class_Terminate()  
        on error resume next 
        irs.close 
        iconn.close 
        set iconn=nothing 
        set irs=nothing 
    End Sub  

’************************************************************* 
’        內容:實現統計功能,一般用select count(*) from table where id>54類似的sql語句. 
’************************************************************* 
    public function getCountBysql(sql) 
        on error resume next 
        dim count 
        count=iconn.execute(sql)(0) 
        getCountBysql=count 
        iconn.close 
    end function  
     
     
     

’************************************************************* 



聯繫我們

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