转至繁体中文版     | 网站首页 | 图文教程 | 资源下载 | 站长博客 | 图片素材 | 武汉seo | 武汉网站优化 | 
最新公告:     敏韬网|教学资源学习资料永久免费分享站!  [mintao  2008年9月2日]        
您现在的位置: 学习笔记 >> 图文教程 >> 站长学院 >> Web开发 >> 正文
面向对象的asp编程之五--adodb的类封装         ★★★★

面向对象的asp编程之五--adodb的类封装

作者:闵涛 文章来源:闵涛的学习笔记 点击数:2016 更新时间:2009/4/23 10:47:19

<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 Function
End Class

''''#################################################################
Function CreateCAdoRecordSet()
         set CreateCAdoRecordSet=new  CAdoRecordSet 
End Function
Class CAdoRecordSet
  
   Public objAdoRecordSet
   Private objAdoCommand
   Private objAdoConnection
  
   ''''==============================================================
   Public Property Get cmdCommandType
           cmdCommandType=objAdoCommand.CommandType
   End Property

   Public Property Let cmdCommandType(ByVal cmdType)
           objAdoCommand.CommandType=cmdType
   End Property
  ''''----------------------
   Public Property Get PageSize
           PageSize=objAdoRecordSet.PageSize
   End Property

   Public Property Let PageSize(ByVal iPageSize)
           objAdoRecordSet.PageSize=iPageSize
   End Property
  ''''--------------------
   Public Property Get AbsolutePage
           AbsolutePage=objAdoRecordSet.AbsolutePage
   End Property

   Public Property Let AbsolutePage(ByVal iAbsolutePage)
           objAdoRecordSet.AbsolutePage=iAbsolutePage
   End Property
  ''''-------------------
  Public Property Get RecordCount
           RecordCount=objAdoRecordSet.RecordCount
   End Property
  ''''-------------------
  Public Property Get pageCount
           pageCount=objAdoRecordSet.pageCount
   End Property
  ''''--------------------
   Public Property Get FieldCount
           FieldCount=objAdoRecordSet.Fields.Count
   End Property
   ''''===============================================================
    
   Private Sub Class_Initialize   '''' Setup Initialize event.

          set  objAdoRecordSet=Server.CreateObject("ADODB.RecordSet")
          objAdoRecordSet.CacheSize = 10
          objAdoRecordSet.CursorType = 3
          objAdoRecordSet.CursorLocation = 3
          objAdoRecordSet.LockType = 3
 
          set  objAdoCommand=Server.CreateObject("ADODB.Command")  
          objAdoCommand.CommandType = 1
    
   End Sub
   Private Sub Class_Terminate   '''' Setup Terminate event.
     
          CloseRecordSet()
          set objAdoRecordSet=nothing
          set objAdoCommand=nothing
          if objAdoConnection<>Empty then
             set objAdoConnection=nothing
       &nb

[1] [2]  下一页


[Web开发]面向对象的JavaScript编程  [Web开发]使用XMLHttp和ADODB.Stream取得远程文件并保存到本…
[Web开发]ASP中利用ADODB.Stream对象将字节流转换为字符流  [Web开发]指南:从MySQL转向ADODB(2)
[Web开发]指南:从MySQL转向ADODB(1)  [Web开发]PHP技巧--通过COM使用ADODB
[Web开发]adodb Stream 详细用法  [Web开发]MMCACHE+PHP5+ADODB出现内存溢出的问题
[Web开发]smarty+adodb+部分自定义类的php开发模式  [Web开发]利用VBScript及ADODB.Steam获取部分格式图象长宽
教程录入:mintao    责任编辑:mintao 
  • 上一篇教程:

  • 下一篇教程:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
      注:本站部分文章源于互联网,版权归原作者所有!如有侵权,请原作者与本站联系,本站将立即删除! 本站文章除特别注明外均可转载,但需注明出处! [MinTao学以致用网]
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)

    同类栏目
    · Web开发  · 网页制作
    · 平面设计  · 网站运营
    · 网站推广  · 搜索优化
    · 建站心得  · 站长故事
    · 互联动态
    更多内容
    热门推荐 更多内容
  • 没有教程
  • 赞助链接
    更多内容
    闵涛博文 更多关于武汉SEO的内容
    500 - 内部服务器错误。

    500 - 内部服务器错误。

    您查找的资源存在问题,因而无法显示。

    | 设为首页 |加入收藏 | 联系站长 | 友情链接 | 版权申明 | 广告服务
    MinTao学以致用网

    Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved.
    闵涛 投放广告、内容合作请Q我! E_mail:admin@mintao.net(欢迎提供学习资源)

    站长:MinTao ICP备案号:鄂ICP备11006601号-18

    闵涛站盟:医药大全-武穴网A打造BCD……
    咸宁网络警察报警平台