asp中Recordset使用說明

來源:互聯網
上載者:User

                     

1.建立Recordset對象

Dim objMyRst

Set objMyRst=Server.CreateObject(“ADODB.Recordset”)

objMyRst.CursorLocation=adUseClientBatch ‘用戶端可批量處理

objMyRst.CursorType=adOpenStatic’游標類型為靜態類型

  注意:Recordset對象不能用Set objMyRst=Connection.Excute strSQL的語句建立,因為其建立的Recordset對象為adOpenFowardOnly不支援記錄集分頁

2.開啟Recordset對象

Dim strSql

strSql=”select * from ietable”

objMyRst.Oepn strSql,ActiveConnection,,,adCmdText

3.設定Recordset的PageSize屬性

objMyRst.PageSize=20

預設的PageSize為10

4.設定Recordset的AbsolutePage屬性

Dim intCurrentPage

intCurrentPage=1

objMyRst.AbsolutePage=intCurrentPage

AbsolutePage為1到Recordset對象的PageCount值

5.顯示資料

  Response.Write("

 

  PrintFieldName(objMyRst)      

  For i=1 To objMyRst.PageSize

          PrintFieldValue(objMyRst)

          objMyRst.MoveNext

          If objMyRst.Eof Then Exit For

  Next

  Response.Write("

<><><>")      

")

  說明:

  1.adOpenStatic,adUseCilentBatch,adCmdText為adovbs.inc定義的常量,要使用的話要把adovbs.inc拷到目前的目錄中並包含於在程式中

<!--#Include File=”adovbs.inc”-->

  2.PrintFielName,PrintFieldValue函數的代碼如下:

asp中recordSet方法屬性

rs.pagesize=3每頁大小(每頁記錄數)
rs.pagecount 由每頁大小和總記錄數算出頁面數
rs.recordcount記錄條數
rs.absolutepage 當前頁

RecordSet.Fields.Count  傳回Recordset中的欄位元。
RecordSet(i).Name  傳回Recordset中第i個欄位的名稱。
RecordSet.RcordCount  傳回Recordset中資料錄的筆數。
RecordSet(i)  傳回RecordSet目前紀錄中的第i個欄位資料。
RecordSet.BookMark  傳回設定的書籍資料以儲存現在紀錄的位置。 RecordSet.AbsolutePostition  將指標移致RecordSet中的某一筆資料上。
RecordSet.PageSize  設定每頁顯示的資料筆數。
RecordSet.PageCount  傳回分頁後的總頁數。
RecordSet.AbsolutePage  傳回目前所在的頁數。
RecordSet("欄位名稱")  傳回指定欄位名稱的資料內容。
RecordSet.BOF  判斷指標是否超過最前面。
RecordSet.EOF  判斷指標是否超過最後面。
RecordSet.MoveFirst  將資料錄指標移至第一筆。
RecordSet.MoveLast  將資料錄指標移至最後一筆。
RecordSet.MoveNext  將資料指標往後移一筆。
RecordSet.MovePrevious  將資料指標往前移一筆。
RecordSet.GetRows  可將Recordset中的資料儲存至陣列中。
RecordSet.AddNew  新增資料至資料表中。
RecordSet.Update  更新目前這筆資料。
RecordSet.Delete  刪除目前這筆資料。
RecordSet.Find  尋找資料

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.