6-14.asp

来自「ASP+SQL Server动态网站开发从基础到实践教程」· ASP 代码 · 共 36 行

ASP
36
字号
<html>

<head>

<title>统计记录数量</title>
</head>

<body>

<%

Dim ConnStr,myConn,mySQL,myRec
ConnStr="Provider=SQLOLEDB;data source=(local);initial catalog=northwind;user id=sa;password=;"  '参照表6-2的连接字符串

set myRec=Server.CreateObject ("ADODB.RecordSet")
myRec.ActiveConnection=ConnStr
myRec.open "select * from customers",,1,1  '打开记录集

response.write "通过RecordCount属性统计的记录数为:" & myRec.RecordCount

myRec.close  '关闭记录集
myRec.open "select count(*) as total from customers",,1,1  '打开记录集
response.write "<br>通过SQL统计的记录数为:" & myRec("total")



myRec.close
set myRec=nothing

%>


</body>

</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?