sub opendb(varsql)
set conn = server.CreateObject ("adodb.connection")
conn.provider="microsoft.jet.oledb.5.0;data source=my15.mdb;"
conn.open vardb
end sub
我的本意就设置成局部变量,全文是这样的
<body>
<%
'声明变量
dim
vardb,varmydomain,vardate,varmessage,varusername,varusername2,varuserid,maruser2id,varlogof
f,varstyle,varcolour,varswearstatus,varpmrand,conn,rs,varsql,vartime,varrooms,varidletime,v
aridle,varlastpost,i
vardb = server.mappath("../myroom/my15.mdb")
'初始化时间变量,记录当前时间
vardate = now()
'错误提示函数
function traperror
response.Write "错误产生!"
end function
'打开数据库函数
sub opendb(varsql)
set conn = server.CreateObject ("adodb.connection")
conn.provider="microsoft.jet.oledb.5.0;data source=my15.mdb;"
conn.open vardb
end sub
'关闭数据库
sub closedb(varsql)
rs.close
conn.close
set rs = nothing
end sub
'执行SQL语句
sub writedb(varsql)
set conn=server.createobject("adodb.connection")
conn.provider="microsoft.jet.loedb.4.0;jet oledb:database password=natterchat"
conn.open vardb
conn.execute(varsql)
conn.close
set conn = nothing
end sub
'打开数据库
call opendb(varsql)
varsql = "select * from users;"
rs.open varsql, conn ,1,3
if rs.eof then
'打开setup表,如果为空,则提示错误
else
varidletime = rs("idletime")
varkickouttime = rs("kickouttime")
end if
call closedb(varsql)
%>
你看这样写,成吗?