asp使用access,count的使用。
VBScript code
<%
dim rs
dim sqlstr
set rs=server.CreateObject("adodb.recordset")
sqlstr="select count(*) as mnum from MessageTable where RecieveMan='admin'and MessageFlag=0"
rs.open sqlstr,conn,1,3
mnum=rs("mnum")
rs.close
set rs=nothing
call closeconn()
response.write mnum
%>
这样为什么没有值呢?原来使用sql数据库。想改为access,结果发现还真不容易。
------解决方案--------------------
dim rs
dim sqlstr
set rs=server.CreateObject("adodb.recordset")
sqlstr="select count(*) as mnum from MessageTable where RecieveMan='admin'and MessageFlag=0"
rs.open sqlstr,conn,1,1
mnum=rs("mnum")
rs.close
set rs=nothing
call closeconn()
response.write mnum
------解决方案--------------------
sqlstr="select RecieveMan,MessageFlag, count(*) as mnum from MessageTable where RecieveMan='admin'and MessageFlag=0 group by RecieveMan,MessageFlag"