能够在数据库使用的实用的数据类型之一是正确和错误数据类型。这会允许简单的正确或者错误的输入。总结这个数据类型的规则和概述一个数量值不一样。下面的例子会读取所有的来自数据库的正确和错误区域的值,然后计算出正确和错误的值和每个完整输出,规则的完整参数,还有完整的真假值百分比。
<%
查询所有对应表格
accessdb="yesno"
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
set rs = server.createobject("ADODB.Recordset")
sql = "select * from [table]"
rs.open sql, cn
移动到第一个记录
rs.movefirst
开始继续直到没有更多的记录的循环
do while not rs.eof
'Check the value of the Yes/No field.
'abstruse and abstruse _false will accumulate
'a numeric summarization of the values contained
'in the table field
检查正确和错误区域值
更多的错误会累积
一个在表格里面的包含值得数量概要
if rs("field") = "True" then
ans_true=ans_true+1
end if
if rs("field") = "False" then
ans_false=ans_false+1
end if
rs.movenext
loop
输出统计
%>
True: <%= ans_true %> <br>
False: <%= ans_false %> <br>
Total: <%= ans_true + ans_false %> <br>
%True: <%= formatnumber(ans_true/(ans_true + ans_false),2) %> <br>
<%
查询所有对应表格
accessdb="yesno"
cn="DRIVER={Microsoft Access Driver (*.mdb)};"
cn=cn & "DBQ=" & server.mappath(accessdb)
set rs = server.createobject("ADODB.Recordset")
sql = "select * from [table]"
rs.open sql, cn
移动到第一个记录
rs.movefirst
开始继续直到没有更多的记录的循环
do while not rs.eof
'Check the value of the Yes/No field.
'abstruse and abstruse _false will accumulate
'a numeric summarization of the values contained
'in the table field
检查正确和错误区域值
更多的错误会累积
一个在表格里面的包含值得数量概要
if rs("field") = "True" then
ans_true=ans_true+1
end if
if rs("field") = "False" then
ans_false=ans_false+1
end if
rs.movenext
loop
输出统计
%>
True: <%= ans_true %> <br>
False: <%= ans_false %> <br>
Total: <%= ans_true + ans_false %> <br>
%True: <%= formatnumber(ans_true/(ans_true + ans_false),2) %> <br>
%False <%= formatnumber(ans_false/(ans_true + ans_false),2) %>
简单生活,希望对大家有用!要觉得本文有价值请分享给您的朋友,生活就是人来人往,分享越多!收获越多!作者:天天ASP家园
本文探讨了数据库中正确和错误数据类型的使用规则,并通过示例代码展示如何读取数据库中的正确与错误区域,计算相关统计数据,如正确与错误的数量、百分比等。
1478

被折叠的 条评论
为什么被折叠?



