asp中关于表的问题,高手看看 急!!!

来源:百度知道 编辑:UC知道 时间:2024/06/01 14:14:37
比如chanpin数据库中有list表,list表中有个youhuo字段,该字段为文本类型,写入该字段的值只有两种1或0(这是为了操作方便)。我想要的操作是用asp访问数据库查询youhuo字段,按月份查询如果该月的youhuo字段全为1则页面提示正确否则有一个是0则页面提示不正确。注:list表中的部分字段list(bh,youhuo,yuefen) bh自动编号yuefen记录月份,数据库为Access.大家帮忙啊,我都搞晕了,先谢了!!
补充说明下啊:表中每个月都有很多条记录的,我的意思就是如果该月youhuo字段的值全为1的时候提示正确 关键就是要全部啊!!!!!有一个是0的话就提示不正确!!!!按照"回答者: defaultred - 江湖新秀"的方法显示的是youhuo字段每条记录的情况了!!!还是先谢谢你的回答了啊!!希望再帮帮我啊!!

set rs =Server.CreateObject("adodb.recordset")
sql="select * from list where yuefen='"&某月&"'"
rs.open sql,conn,1,1
flag = false
while not rs.eof
if rs("youhuo")="0" then
flag=true
end if
rs.movenext
wend
if flag = true then
response.write "不正确"
else
response.write "正确"
end if

你只要查询该月的是否有0就行了。有记录就表示不正确!

(借用上面的代码)
set rs =Server.CreateObject("adodb.recordset")
sql="select * from list where yuefen='"&某月&"' and youhuo='0'"
rs.open sql,conn,1,1
flag = true
if not rs.eof then
flag= false
end if

if flag = true then
response.write "不正确"
else
response.write "正确"
end if