网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 天空资源网 >> 电脑技术 >> 编程技术 >> ASP >> 电脑技术正文
  面向对象的asp编程之五--adodb的类封装          【字体:
面向对象的asp编程之五--adodb的类封装
作者:网络    电脑技术来源:www.20888.net    点击数:    更新时间:2006-12-9    

<Script language="vbscript" runat="server">
'****************************************************************
' Script Compont Object Model
' Design for Active Server Pages
' Copyright 2004  Version 2.0
' Made by 尹曙光
' ****************************************************************
'
'                      ADODB的类封装
'
'*****************************************************************
'#################################################################
Function CreateCAdoConnection()
      set CreateCAdoConnection=new CAdoConnection
End Function

Class CAdoConnection
  
   Public objAdoConnection
 
  '===============================================================
   Public Property Get ConnectionString
           ConnectionString=objAdoConnection.ConnectionString
   End Property

   Public Property Let ConnectionString(ByVal connString)
           objAdoConnection.ConnectionString=connString
   End Property
 
  '===============================================================
  Private Sub Class_Initialize   ' Setup Initialize event.

       On Error Resume Next
      
       set objAdoConnection=Server.CreateObject("ADODB.Connection")
       objAdoConnection.ConnectionTimeout = 15
       objAdoConnection.CommandTimeout = 30
       objAdoConnection.CursorLocation = 3
      
   End Sub
   Private Sub Class_Terminate   ' Setup Terminate event.
     
      CloseDbConn()
      Set objAdoConnection=nothing 
     
   End Sub

   'Open Adodb.Connection
   Public Sub OpenDbConn(dbLink)
         On Error Resume Next
         objAdoConnection.ConnectionString=dbLink
         OpenDbConn2()
   End Sub
  
    Public Sub OpenDbConn2()
         On Error Resume Next
         CloseDbConn()
         objAdoConnection.Open()
         if err.number>0 then
            Response.Write "打开娄据库失败!"
            Response.End
         end if
   End Sub
  
   Public Sub CloseDbConn()
        if objAdoConnection.State=1 then
           objAdoConnection.Close
        end if   
   End Sub
  
   Public Function GetConnection()
        set GetConnection=objAdoConnection
   End Function

   Public Sub AdoError()
      Response.Write("错误描述 ( 适用于技术人员 ):<br>")
      if (objAdoConnection.errors.count>0) then '有错误产生
           for i=1 to objConn.errors.count
              Response.Write i&":"&objAdoConnection.errors(i-1).description&"<br>"
            next  'end of for
            set AdoError=true
      end if
      set AdoError=false
   End Sub
  
   Public Function HaveError()
         if (objAdoConnection.errors.count>0) then '有错误产生
            HaveError=true
          else
            HaveError=false
          end if   
   End Function
   '--------------------------------------------------------------
   Public Function Execute(sql)
         on Error resume next
         objAdoConnection.Execute(sql)
         if err.number>0 then
            Execute=false
          else
            Execute=true
          end if 
   End Function
  
   Public Function  ExecuteToRs(sql)
         on Error resume next
         set ExecuteToRs=objAdoConnection.Execute(sql)  
   End

[1] [2] [3] 下一页

电脑技术录入:lcsnow    责任编辑:lcsnow 
  • 上一篇电脑技术:

  • 下一篇电脑技术:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    没有相关电脑技术
    Copyright @ 2006 天空资源网 All Rights Reserved
    Designed by: lcsnow E-mail: admin#seesky.net
    皖ICP备05005479号