日期:2014-05-16  浏览次数:20894 次

ASP页面取数据库值
pix=request("pixs")
if lvl = "" then 
response.write "非法用户?"
objcn.close
set objcn = nothing
response.end

end if

上面是我在一个asp页面看到的代码,意思是权限为空的话显示非法用户,我现在想在asp页面中取出数据库中某个字段的值,不知道怎么实现?求支援呐。。。
------解决方案--------------------
不直接用游标读数据库就好了。。

pix=request("pixs")
set rs=objcn.execute("你的sql语句")
'处理rs游标的代码
if lvl = "" then 
    response.write "非法用户?"
    objcn.close
    set objcn = nothing
    response.end
 
end if

------解决方案--------------------
pix=request("pixs")
set rs=objcn.execute("select id from yourtable where条件")
if not( rs.eof or rs.bof) then id=rs(0)


去学下基础了,这么基础的都不会
------解决方案--------------------
pix=request("pixs")
if lvl = "" then 
    response.write "非法用户?"
    objcn.close
    set objcn = nothing
    response.end
 
end if

这个lvl 是变量还是从数据库取出来的?
 去数据库的值,首先要读出数据表
sql1="select* from table"
set jdt=server.CreateObject("adodb.recordset")
 jdt.open sql1,conn,1,1
if not jdt.eof then '有值
s=jdt("值")
end if
response.write(s) '取值

循环取值
do while not jdt.eof
s=jdt("值")
jdt.movenext
loop