首页 >> 读书频道 >> 电脑 >> 当Recordcount返回-1时怎样计算记录数目
 
· 如何实现多记录的分页显示
· 在ASP中用集合成批操作
· RecordSet的Lo
· RecordSet的Cu
· ADO Recordse
· 获得删除纪录的个数
· Recordset Cu
· 数据库设计经验谈
· 利用SQL发E-MAIL
· 影响SQL server
· 用ASP调用SQL Se
· 如何操作SQL的TXT字
 
· 全唐诗卷四十六
· 韩剧《布拉格恋人》剧情介
· 夜航船[作者:明·张岱]
· 局外人[作者:韩·可爱淘
· 现场流行病学
· 源氏物语[日本:紫式部]
· 红楼梦:120回全本[清
· 武林寓言故事
· 2006高考录取规则
· 首批中国世界名牌产品和2
· 济南美食大全
· 管理三十六计
 
· (出租)中动商场部分及写
· (出租)中动动漫基地&#
· 喜剧学院
· 《善德女王》剧情介绍
· 魔女18号 剧情
· 丑女无敌剧情介绍
· 魔女幼熙剧情介绍
· 龙游天下剧情介绍
· 震撼世界的七日剧情介绍
· 静静的白桦林剧情介绍
· 心情日记—老公今天我想对
· 旗舰剧情介绍
欢迎来到月影社区!如果您觉得这里不错,请推荐给您的朋友们。月影社区:http://wf66.com/

当Recordcount返回-1时怎样计算记录数目


查看有无更新版本

关键字:ASP与数据库 2006-8-28

 

<%
' BEGIN CONSTANT DEFINITION

' The following command includes the ADODB VBScript
constants file.
' If you can't find your copy you can download a copy from:
' http://www.asp101.com/samples/download/adovbs.inc
' It may not be the most recent copy so use it at your own
risk.

%>
<!-- #INCLUDE FILE="./download/adovbs.inc" -->
<%

' DB Configuration variables
' After this, strictly used as if it were a Const.
Dim DB_CONNSTRING
DB_CONNSTRING = "DRIVER={Microsoft Access Driver
(*.mdb)};DBQ=" & Server.Mappath("./db_scratch.mdb") & ";"

' Now we override the above setting so the sample uses our
SQL server.
' Comment out the following line to use the sample Access
DB.
DB_CONNSTRING = Application("SQLConnString") & _
"UID=" & Application("SQLUsername") & ";" & _
"PWD=" & Application("SQLPassword") & ";"

' END CONSTANT DEFINITION
%>

<%
Dim rsCount ' The recordset object

' Create an instance of an ADO Recordset
Set rsCount = Server.CreateObject("ADODB.Recordset")

' Open RS
' I'm actually doing this directly (without a connection object) to
keep
' the code short and to the point. I'm opening the RS with a static
' cursor, read only, and telling it that "scratch" is a table name and
' not a SQL command. If I don't specify how to open the rs, I'd get
the
' default cursor type which doesn't support .RecordCount!
rsCount.Open "scratch", DB_CONNSTRING, adOpenStatic, adLockReadOnly,
adCmdTable

' Show RecordCount
' I dress it up and pop it into the middle of a sentence, but you can
' do whatever you want with it.
Response.Write "This table currently has <B><FONT COLOR=""#FF0000"">"
Response.Write rsCount.RecordCount ' This is the line that does it!
Response.Write "</FONT></B> records in it!<BR>" & vbCrLf


'=====================================================================
=
' BEGIN TABLE DISPLAY
' Now I'm going to display the table if they requested it just so you
' have something to look at! This really doesn't pertain to the topic
' of this sample so I'm going to keep the code short but feel free to
' look it over and if you do please notice the pretty HTML it outputs!
' Ugly HTML output is a pet peeve of mine! ;)
If LCase(Request.QueryString("showtable")) = "true" Then
Dim Field ' Field Looper for display
Dim bColor ' Use for showing alternating colors
bColor = False

' Spacers and intro
Response.Write "<BR>" & vbCrLf & "They are:<BR>" & vbCrLf
& "<BR>" & vbCrLf

' Start the table
Response.Write "<TABLE BORDER=""1"">" & vbCrLf

' Write Titles
Response.Write vbTab & "<TR>" & vbCrLf
For Each Field in rsCount.Fields
Response.Write vbTab & vbTab & "<TD
BGCOLOR=""#CCCCCC""><B>" & Field.Name & "</B></TD>" & vbCrLf
Next 'Field
Response.Write vbTab & "</TR>" & vbCrLf

' Loop through records outputting data
Do While Not rsCount.EOF
Response.Write vbTab & "<TR>" & vbCrLf
For Each Field in rsCount.Fields
Response.Write vbTab & vbTab & "<TD
BGCOLOR="""

' Decide what color to output
If bColor Then
Response.Write "#CCCCFF" '
Light blueish
Else
Response.Write "#FFFFFF" ' White
End If

Response.Write """>" & Field.Value
& "</TD>" & vbCrLf
Next 'Field
Response.Write vbTab & "</TR>" & vbCrLf

' Toggle our colors
bColor = Not bColor
rsCount.MoveNext
Loop

' End the table
Response.Write "</TABLE>" & vbCrLf
Response.Write "<BR><A HREF=""db_count.asp"">Hide the
table</A>" & vbCrLf
Else
Response.Write "<BR><A HREF=""db_count.asp?
showtable=true"">Show the table</A>" & vbCrLf
End If
' END TABLE DISPLAY - Now back to our regularly scheduled code!
'=====================================================================
=

' Close and dispose of recordset object
rsCount.Close
Set rsCount = Nothing
%>

当Recordcount返回-1时怎样计算记录数目

[ 1 ]
当Recordcount返回-1时怎样计算记录数目 num

打印本页 关闭

关于我们版权声明本站导航友情连结作品演示 TOP↑