当前位置: 首页 > 图文教程 > 网络编程 > ASP > 一个简单的asp数据库操作类

ASP
用ASP编写网络传呼机
用ASP+CSS实现随机背景
ASP下载系统防盗链方法
用ASP编写下载网页中所有资源的程序
Request.ServerVariables应用
解决Asp程序的Server.CreateObject错误
ASP实现TCP端口扫描的方法
源码实例:ASP实现远程保存图片
用ASP+DLL实现WEB方式修改服务器时间
ASP使用MySQL数据库全攻略
ASP+SQL Server构建网页防火墙
教程/ASP 十天学会ASP之第二天
教程/ASP 十天学会ASP之第四天
教程/ASP 十天学会ASP之第五天
教程/ASP 十天学会ASP之第六天
教程/ASP 十天学会ASP之第七天
教程/ASP 十天学会ASP之第八天
教程/ASP 十天学会ASP之第九天
教程/ASP 十天学会ASP之第十天
关于学习ASP和编程的28个观点

ASP 中的 一个简单的asp数据库操作类


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 23 ::
收藏到网摘: n/a

<%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'数据库操作类
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'名称:Class_DBOperate
'版本:0.2
'作者:qihangnet
'更新:2005年6月14日
'作用:简化数据库操作的流程
'授权:免费使用
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Class Class_DBOperate
'************************************
'变量定义
'************************************
'Conn ---------- 数据库连接对象
'Conn_Str ------ 数据库连接字符串
Private Conn,Conn_Str
'************************************
'实例 初始化/终止
'************************************
Private Sub Class_Initialize()
Set Conn = Server.CreateObject("ADODB.Connection")
End Sub
Private Sub Class_Teriminate()
Set Conn = Nothing
End Sub
'************************************
'属性
'************************************
'输出数据库连接字符串
' 返回值类型:string
Property Get ConnectString
ConnectString = Conn_Str
End Property
'设置数据库连接字符串(数据库连接字符串)
' 参数:str --- string
Property Let ConnectString(str)
Conn_Str = str
End Property
'************************************
'事件
'************************************
'数据库打开
Public Sub DB_Open() 。
Conn.ConnectionString = Conn_Str
Conn.Open
End Sub
'数据库关闭
Public Sub DB_Close()
Conn.Close
End Sub
'************************************
'方法
'************************************
'数据库查询(sql语句)
' 参数及类别:sql ---- string
' 返回值类型:记录集
' 前提:数据库状态为打开
Public Function DB_Select(sql)
Set DB_Select = Conn.Execute(sql)
End Function
'数据库执行(SQL语句)
' 参数及类别:sql ---- string
' 返回值类型:整形
' 返回值含义:受影响行数
' 前提:数据库状态为打开
Public Function DB_Excute(sql)
Dim rs_affected
Conn.Execute sql,rs_affected
DB_Excute = rs_affected
End Function
End Class
%>