解释ASP+SQL代码。i因为我不懂ASP+SQL,所以我要最详细的解释,最详细解释者得分。谢谢!
1.数据库配置,请解释以下代码的意思。classdatabasepublicconn,db,connstrpublicsubloaddata()connstr="driv...
1.数据库配置,请解释以下代码的意思。
class database
public conn,db,connstr
public sub loaddata()
connstr="driver={sql server};server=127.0.0.1;database=wygl;uid=sa;pwd=sa;"
end sub
public sub connect()
set conn=server.createobject("adodb.connection")
conn.open connstr
end sub
public function execute(sql)
set rs=server.createobject("adodb.recordset")
if isobject(conn)=false then
connect()
rs.open sql,conn,1,3
else
rs.open sql,conn,1,3
end if
set execute=rs
end function
public sub disconnect()
conn.close
set conn=nothing
end sub
end class
set data=new database
data.loaddata
2.核对管理员的账户和密码,请解释以下代码。
data.admin()
if request.querystring("action")="chk" then
call chk()
end if
if request.querystring("action")="" then
if data.isadmin then
response.redirect("index.asp")
response.end()
else
call login()
end if
end if
sub login()
dim ados,getcode
set ados=server.createobject("adodb.stream")
if err then
getcode=9999
end if
end sub
3.修改密码。请解释以下代码:
head()
data.admin()
if data.isadmin=false then
errmsg="<li> 你没有登陆或者不是管理员。请<a href='login.asp' target='_top'>登陆</a>。"
response.redirect("show.asp?action=adminerr&errmsg="&errmsg&"")
response.end()
end if
if request.querystring("action")="update_info" then
call update_info()
else
call main()
end if
footer()
sub update_info()
dim username,password_org,password,password2,code
username = trim(request.form("username"))
password_org = trim(request.form("password_org"))
password = trim(request.form("password_new"))
password2 = trim(request.form("password_new2"))
code=trim(request.form("code"))
4.请解释以下代码:
select case request.querystring("action")
case "save"
call saveset()
case "add"
call add()
case "admin"
call admin()
case "edit"
call edit()
case "saveedit"
call saveedit()
case "del"
call del()
case else
call add()
end select
5。请解释以下代码
select case request.querystring("action")
case "save"
call saveset()
case "add"
call add()
case "admin"
call admin()
case "edit"
call edit()
case "saveedit"
call saveedit()
case "del"
call del()
case else
call add()
end select
footer()
sub saveset()
data.chkadmin(0)
dim newstitle,article,txtsource,txtwriter
tsnum = request.form("tsnum")
receiver = request.form("receiver")
tscontent = request.form("tscontent")
processor = request.form("processor")
tsname = request.form("tsname")
remark=request.form("remark")
tsdate=request.form("tsdate")
end sub 展开
class database
public conn,db,connstr
public sub loaddata()
connstr="driver={sql server};server=127.0.0.1;database=wygl;uid=sa;pwd=sa;"
end sub
public sub connect()
set conn=server.createobject("adodb.connection")
conn.open connstr
end sub
public function execute(sql)
set rs=server.createobject("adodb.recordset")
if isobject(conn)=false then
connect()
rs.open sql,conn,1,3
else
rs.open sql,conn,1,3
end if
set execute=rs
end function
public sub disconnect()
conn.close
set conn=nothing
end sub
end class
set data=new database
data.loaddata
2.核对管理员的账户和密码,请解释以下代码。
data.admin()
if request.querystring("action")="chk" then
call chk()
end if
if request.querystring("action")="" then
if data.isadmin then
response.redirect("index.asp")
response.end()
else
call login()
end if
end if
sub login()
dim ados,getcode
set ados=server.createobject("adodb.stream")
if err then
getcode=9999
end if
end sub
3.修改密码。请解释以下代码:
head()
data.admin()
if data.isadmin=false then
errmsg="<li> 你没有登陆或者不是管理员。请<a href='login.asp' target='_top'>登陆</a>。"
response.redirect("show.asp?action=adminerr&errmsg="&errmsg&"")
response.end()
end if
if request.querystring("action")="update_info" then
call update_info()
else
call main()
end if
footer()
sub update_info()
dim username,password_org,password,password2,code
username = trim(request.form("username"))
password_org = trim(request.form("password_org"))
password = trim(request.form("password_new"))
password2 = trim(request.form("password_new2"))
code=trim(request.form("code"))
4.请解释以下代码:
select case request.querystring("action")
case "save"
call saveset()
case "add"
call add()
case "admin"
call admin()
case "edit"
call edit()
case "saveedit"
call saveedit()
case "del"
call del()
case else
call add()
end select
5。请解释以下代码
select case request.querystring("action")
case "save"
call saveset()
case "add"
call add()
case "admin"
call admin()
case "edit"
call edit()
case "saveedit"
call saveedit()
case "del"
call del()
case else
call add()
end select
footer()
sub saveset()
data.chkadmin(0)
dim newstitle,article,txtsource,txtwriter
tsnum = request.form("tsnum")
receiver = request.form("receiver")
tscontent = request.form("tscontent")
processor = request.form("processor")
tsname = request.form("tsname")
remark=request.form("remark")
tsdate=request.form("tsdate")
end sub 展开
2个回答
展开全部
class database'定义类database
public conn,db,connstr'声明变量
public sub loaddata()'定义公共函数loaddata(),连接数据库用的
connstr="driver={sql server};server=127.0.0.1;database=wygl;uid=sa;pwd=sa;"
end sub
public sub connect()'定义公共函数connect(),打开数据库连接用的
set conn=server.createobject("adodb.connection")
conn.open connstr
end sub
public function execute(sql)'定义公共函数execute(sql),执行sql语句
set rs=server.createobject("adodb.recordset")
if isobject(conn)=false then
connect()
rs.open sql,conn,1,3
else
rs.open sql,conn,1,3
end if
set execute=rs
end function
public sub disconnect()'定义公共函数,关闭数据库连接
conn.close
set conn=nothing
end sub
end class
set data=new database '声明data为database类
data.loaddata'连接数据库
2.核对管理员的账户和密码,请解释以下代码。
data.admin()'管理员登录验证函数
if request.querystring("action")="chk" then
call chk()
end if
if request.querystring("action")="" then
if data.isadmin then
response.redirect("index.asp")
response.end()
else
call login()
end if
end if
sub login()'生成验证码
dim ados,getcode
set ados=server.createobject("adodb.stream")
if err then
getcode=9999
end if
end sub
3.修改密码。请解释以下代码:
head()'头部
data.admin()'验证管理员登录
if data.isadmin=false then'未登录提示错误信息
errmsg="<li> 你没有登陆或者不是管理员。请<a href='login.asp' target='_top'>登陆</a>。"
response.redirect("show.asp?action=adminerr&errmsg="&errmsg&"")
response.end()
end if
if request.querystring("action")="update_info" then'如果action="update_info",调用update_info()函数
call update_info()
else
call main()'调用主函数main()
end if
footer()'底部
sub update_info()'定义update_info()函数,修改密码用的
dim username,password_org,password,password2,code
username = trim(request.form("username"))
password_org = trim(request.form("password_org"))
password = trim(request.form("password_new"))
password2 = trim(request.form("password_new2"))
code=trim(request.form("code"))
4.请解释以下代码:
select case request.querystring("action")'根据action变量的不同值调用不同的函数
case "save"
call saveset()
case "add"
call add()
case "admin"
call admin()
case "edit"
call edit()
case "saveedit"
call saveedit()
case "del"
call del()
case else
call add()
end select
5。请解释以下代码
select case request.querystring("action")'根据action变量的不同值调用不同的函数
case "save"
call saveset()
case "add"
call add()
case "admin"
call admin()
case "edit"
call edit()
case "saveedit"
call saveedit()
case "del"
call del()
case else
call add()
end select
footer()
sub saveset()'定义saveset()函数,保存数据用的
data.chkadmin(0)
dim newstitle,article,txtsource,txtwriter
tsnum = request.form("tsnum")
receiver = request.form("receiver")
tscontent = request.form("tscontent")
processor = request.form("processor")
tsname = request.form("tsname")
remark=request.form("remark")
tsdate=request.form("tsdate")
end sub
public conn,db,connstr'声明变量
public sub loaddata()'定义公共函数loaddata(),连接数据库用的
connstr="driver={sql server};server=127.0.0.1;database=wygl;uid=sa;pwd=sa;"
end sub
public sub connect()'定义公共函数connect(),打开数据库连接用的
set conn=server.createobject("adodb.connection")
conn.open connstr
end sub
public function execute(sql)'定义公共函数execute(sql),执行sql语句
set rs=server.createobject("adodb.recordset")
if isobject(conn)=false then
connect()
rs.open sql,conn,1,3
else
rs.open sql,conn,1,3
end if
set execute=rs
end function
public sub disconnect()'定义公共函数,关闭数据库连接
conn.close
set conn=nothing
end sub
end class
set data=new database '声明data为database类
data.loaddata'连接数据库
2.核对管理员的账户和密码,请解释以下代码。
data.admin()'管理员登录验证函数
if request.querystring("action")="chk" then
call chk()
end if
if request.querystring("action")="" then
if data.isadmin then
response.redirect("index.asp")
response.end()
else
call login()
end if
end if
sub login()'生成验证码
dim ados,getcode
set ados=server.createobject("adodb.stream")
if err then
getcode=9999
end if
end sub
3.修改密码。请解释以下代码:
head()'头部
data.admin()'验证管理员登录
if data.isadmin=false then'未登录提示错误信息
errmsg="<li> 你没有登陆或者不是管理员。请<a href='login.asp' target='_top'>登陆</a>。"
response.redirect("show.asp?action=adminerr&errmsg="&errmsg&"")
response.end()
end if
if request.querystring("action")="update_info" then'如果action="update_info",调用update_info()函数
call update_info()
else
call main()'调用主函数main()
end if
footer()'底部
sub update_info()'定义update_info()函数,修改密码用的
dim username,password_org,password,password2,code
username = trim(request.form("username"))
password_org = trim(request.form("password_org"))
password = trim(request.form("password_new"))
password2 = trim(request.form("password_new2"))
code=trim(request.form("code"))
4.请解释以下代码:
select case request.querystring("action")'根据action变量的不同值调用不同的函数
case "save"
call saveset()
case "add"
call add()
case "admin"
call admin()
case "edit"
call edit()
case "saveedit"
call saveedit()
case "del"
call del()
case else
call add()
end select
5。请解释以下代码
select case request.querystring("action")'根据action变量的不同值调用不同的函数
case "save"
call saveset()
case "add"
call add()
case "admin"
call admin()
case "edit"
call edit()
case "saveedit"
call saveedit()
case "del"
call del()
case else
call add()
end select
footer()
sub saveset()'定义saveset()函数,保存数据用的
data.chkadmin(0)
dim newstitle,article,txtsource,txtwriter
tsnum = request.form("tsnum")
receiver = request.form("receiver")
tscontent = request.form("tscontent")
processor = request.form("processor")
tsname = request.form("tsname")
remark=request.form("remark")
tsdate=request.form("tsdate")
end sub
追问
sub login()'生成验证码
dim ados,getcode
set ados=server.createobject("adodb.stream")
if err then
getcode=9999
end if
end sub
你好,可以详细解释一下以上生成验证码的整个过程吗?我想知道随机验证码是怎么生成的,用的是什么方法。这个很重要,谢谢!
追答
不好意思,你这个函数里没有具体的生成过程.
dim ados,getcode '这句声明变量
set ados=server.createobject("adodb.stream")'这句创建一个用来生成文件的对象ados
if err then‘如果出错,则让验证码等于9999
getcode=9999
end if
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询