📄 mdbaction.asp
字号:
<!--#include file="global.asp"-->
<%
codepage="65001"
server.scripttimeout=20
'这个文件你没有看的必要性
'________________________________________________________________________________________
function recordSQL(sqlpara)
on error resume next
dim conn,rs,temp,i,record1,temp2,columNum,j,temp3
set conn=new mdbaction'建立连接
temp=split(sqlpara,";")
for i=0 to ubound(temp)
conn.sql=temp(i)
record1=""'请空对象
set rs=conn.record
if rs.recordcount<>0 then
temp2=split(mid(temp(i),1,instr(temp(i),"from")),",")
columNum=ubound(temp2)
do while not rs.eof
for j=0 to columNum
record1=record1 & rs(j)&"<@>"'列标
next
record1=mid(record1,1,instrrev(record1,"<@>")-1)'取消最后的列标
record1=record1 & "<#>"'行标
rs.movenext
loop
record1=mid(record1,1,instrrev(record1,"<#>")-1)'取消最后的行标
else
record1=record1 & "there is no match record exist"
end if
temp3=temp3 & record1 & "<another>"'另一个SQL语句
rs.close
set rs=nothing
next
temp3=mid(temp3,1,instrrev(temp3,"<another>")-1)
recordsql=temp3
set conn=nothing
if err then:errcount=errcount+1:errMessage=errmessage & " recordSQL发生问题<br/>":err.clear:end if
end function
class mdbaction
public readORwrite'定义recordset是1,1或1,3默认1,1
private mdb_Path'数据库相对路径
private conn'打开数据库
private isconnect'是否已建立连接,标签
private sql_inside'SQL语句
private isSys'是否返回系统表名,默认为否
'只写
public property let sql(v)
sql_inside=v
end property
private sub Class_initialize()
'构造函数,进行初始化
mdb_path=con_mdbpath'常量
isConnect=false'还没建立连接
readORwrite="read"
isSys=false
call connopen()'打开数据库连接
end sub
private sub class_terminate()
call connclose()'关闭连接
end sub
private sub connopen()
'打开连接
on error resume next
dim filePath,Connstr
filepath=server.mappath(mdb_path)
Connstr = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & filepath
Set conn=server.CreateObject("adodb.connection")
conn.open connstr'打开数据库
isconnect=true'已建立
If Err.number<>0 or conn.errors.count<>0 Then
conn.close
set conn=nothing
isconnect=false'说明conn已经关闭
err.Clear
errcount=errcount+1
errMessage=errMessage & " 不能连接数据库<br/>"
end if
end sub
private sub connclose()
'关闭连接
if isconnect then'若已建立
conn.close
set conn=nothing
end if
end sub
'_______________________________________________________________________________
public function record()
'取得记录
on error resume next
dim rs
set rs=server.createobject("adodb.recordset")
'我常用的也就这两种
if readORwrite="write" then
rs.open sql_inside,conn,1,3'调用update时才用到,但norecordSQL函数已解
else
rs.open sql_inside,conn,1,1'默认方法
end if
set record=rs'跳出
set rs=nothing
if err OR conn.errors.count<>0 then
errcount=errcount+1
errMessage=errMessage & " recordSQL有问题</br>"
err.clear
end if
end function
end Class
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -