当前位置: 网学 > 编程文档 > ASP > 正文

asp中记录集对象的getrows和getstring用法分析

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/16
an into the last record in
'' in the recordset. This time we''re going to get all the data
'' in one fell swoop and dump it into a string so we can
'' disconnect from the DB as quickly as possible.
strDBData = rstGetString.GetString()

'' Since I''m doing this twice for illustration... I reposition
'' at the beginning of the RS before the second call.
rstGetString.MoveFirst

'' This time I ask for everything back in HTML table format:
strDBDataTable = rstGetString.GetString(adClipString, -1, _
&"</td><td>", "</td></tr>" & vbCrLf & "<tr><td>", " ")

'' Because of my insatiable desire for neat HTML, I actually
'' truncate the string next. You see, GetString only has
'' a parameter for what goes between rows and not a seperate
'' one for what to place after the last row. Because of the
'' way HTML tables are built, this leaves us with an extra
'' <tr><td> after the last record. GetString places the
'' whole delimiter at the end since it doesn''t have anything
'' else to place there and in many situations this works fine.
'' With HTML it''s a little bit weird. Most developers simply
'' close the row and move on, but I couldn''t bring myself to''
leave the extra row... especially since it would have a
'' different number of cells then all the others.
'' What can I say... these things tend to bother me. ;)
strDBDataTable = Left(strDBDataTable, Len(strDBDataTable) - Len("<tr><td>"))

'' Some notes about .GetString:
'' The Method actually takes up to 5 optional arguments:
'' 1. StringFormat - The format in which to return the
'' recordset text. adClipString is the only
'' valid value.
'' 2. NumRows - The number of rows to return. Defaults
'' to -1 indicating all rows.
'' 3. ColumnDelimiter - The text to place in between the columns.
'' Defaults to a tab character
'' 4. RowDelimiter - The text to place in between the rows
'' Defaults to a carriage return
'' 5. NullExpr - Expression to use if a NULL value is
'' returned. Defaults to an empty string.
'' Close our recordset and connection and dispose of the objects.
'' Notice that I''m able to do this before we even worry about
'' displaying any of the data!
rstGetString.Close
Set rstGetString = Nothing
cnnGetString.Close
Set cnnGetString = Nothing

'' Display the table of the data. I really don''t need to do
'' any formatting since the GetString call did most everything
'' for us in terms of building the table text.
Response.Write "<table border=""1"">" & vbCrLf
Response.Write "<tr><td>"
Response.Write strDBDataTable
Response.Write "</table>" & vbCrLf
'' FYI: Here''s the output format you get if you cann GetString
'' without any parameters:
Response.Write vbCrLf & "<p>Here''s the unformatted version:</p>" & vbCrLf
Response.Write "<pre>" & vbCrLf
Response.Write strDBDataResponse.Write "</pre>" & vbCrLf

'' That''s all folks!
%>

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号