asp实现简单数据库连接类
实现了简单的数据库连接,得到记录集,得到二维数组,执行某个语句,其实这个类可以继续扩充,比如先读取变量,得到执行次数,简单分页等等。。,篇幅有限,自己扩充
'----------------------------------------------
'数据库操作
'----------------------------------------------
'简化的数据类
Class dbconn
public connstr,conn,queryCount,die_err
private connstate
Private Sub Class_Initialize
queryCount=0
connstate = false
die_err = true
End Sub
'构造
Sub Conn_Open
on error resume next
set conn = server.CreateObject("adodb.connection")
conn.connectiontimeout = 120
Conn.Open connstr
if err then
if die_err = true then die "数据库连接错误!"
else
connstate= true
end if
End Sub
'得到记录集
Function getRs(byval sqlStr,byval vtype)
On Error Resume Next
if cint(vtype) <> 3 then vtype =1 end if
if connstate = false then call Conn_Open
set getrs = server.CreateObject("ADODB.RECORDSET")
getrs.open sqlStr,conn,1,vtype
queryCount = queryCount+1
if Err then
if die_err = true then die sqlStr
if die_err = true then die "数据库得到记录集错误!"
end if
End Function
'得到单一的值
Function getVal(byval sqlstr)
On Error Resume Next
if connstate = false then call Conn_Open
dim rs : set rs =conn.execute(sqlstr)
if rs.eof then
getVal =""
else
getVal = rs(0)
end if
rs.close : set rs = nothing
End Function
Function exec(Byval sqlstr)
if connstate = false then call Conn_Open
conn.execute(sqlstr)
End Function
'得到数组
Function getArray(Byval sqlstr)
on error resume next
if connstate = false then call Conn_Open
dim rs : set rs =conn.execute(sqlstr)
if rs.eof then getArray = "" else getArray = rs.getrows
rs.close : set rs = nothing
queryCount = queryCount+1
if Err then
if die_err = true then die "数据库得到数组错误!"
end if
End Function
'析构
Public Sub Class_Terminate()
if connstate = true
相关文档:
option explicit
dim str1,str2
str1 ="order|||shiyang:100,mayang:200"
str2 = "book|||shuming:计算机,dingjia:100"
'声明2个全局对象
'放弃了一开始希望用数组存储的方式,那个虽然效率更高,但是需要自定义的array_pushobj函数,所以此处不做讨论了
dim objname_g
dim classname_g
'返回实体类
function getO ......
原文地址:http://bbs.bccn.net/thread-225295-1-1.html
如果机房马上要关门了,或者你急着要和MM约会,请直接跳到第四个自然段。
以下叙述的脚本包括服务器端脚本和客户端的脚本,服务器端脚本指在服务器上运行的那部分脚本,比如常见的Response.Write显然是在服务器上运行的,服务器端脚本可以使用VBScript和JS ......
遍历XML文档
对于下面的一段XML代码:
XML文档实例books.xml,如下所示:
<?xml version="1.0" encoding="gb2312" ?>
<books>
<book status="已售完">
<author>破破</author>
<title>XML入门</title >
</book>
<book statu ......
GUID概述
Globally Unique Identifier(全球唯一标识符) 也称作 UUID(Universally Unique
IDentifier)
GUID/UUID是通过特定算法产生的一个二进制长度为128位的数字。
在空间上和时间上具有唯一性,保证同一时间不同地方产生的数字不同。
世界上的任何两台计算机都不会生成重复的 GUID 值。GUID 主要用于在拥有多个节 ......