實驗Recordset.Movenext,Recordset.Previous,Recorset...等移動記錄_第1頁
實驗Recordset.Movenext,Recordset.Previous,Recorset...等移動記錄_第2頁
實驗Recordset.Movenext,Recordset.Previous,Recorset...等移動記錄_第3頁
全文預覽已結束

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

1、    我在實驗Recordset.Movenext,Recordset.Previous,Recorset.等移動記錄的時候遇到了困難.我用Access做后臺數(shù)據(jù)庫,通過一個查詢條件查詢得一個記錄集,我想用一個表格實現(xiàn)記錄的逐條瀏覽(不是一組記錄分頁瀏覽). 即"共查到*條記錄,現(xiàn)在是第*條",單擊"Next"按鈕后下一條記錄的內容顯示在表格中.我用如下代碼實現(xiàn)(見最后)發(fā)現(xiàn)若將Rst.Open "select * from 某表 where 從某個Form獲取的查詢條件" 改成 &

2、#160;Rst.Open "select * from 某表"(相當于不做查詢動作)后, 記錄的瀏覽功能才得以實現(xiàn).否則總是出現(xiàn)" EOF或BOF為真 "的錯誤提示.可我明明可以從"某表"中 "select. where."到好幾個記錄的!總之如何將"記錄的逐條瀏覽"和"select * from 某表 where 從某個Form獲取的查詢條件" 結合起來?望予以指點為感!楊利2000/4/13程序代碼:<% LANGUAGE=VBScript %><!-

3、 #Include file="ADOVBS.INC" -><html><head><title></title></head><body BGCOLOR="#FFFFF0"><h3 align="center"><font face="隸書" color="#004080"><big>現(xiàn)在您可以編輯以下記錄</big></font></h3>&l

4、t;!- 在服務器上創(chuàng)建 Connection 和 Recordset 對象 -><%'創(chuàng)建并打開 Connection 對象。Set cn=Server.CreateObject("ADODB.Connection")     cn.Open "DSN=數(shù)據(jù)庫名" '創(chuàng)建并打開 Recordset 對象。Set Rst = Server.CreateObject("ADODB.Recordset")    Rst.Active

5、Connection = cn    Rst.CursorType = adOpenKeyset    Rst.LockType = adLockOptimistic   Rst.Open "select * from 某表 where 性別='"&request.form("t1")&"'"(執(zhí)行這句大有問題)Rst.Open "select * from 某表 where 性別=&

6、#39;男'"(執(zhí)行這句有點問題)Rst.Open "select * from hr_base"(執(zhí)行這句沒有問題)' 檢查 Request.Form 集合以查看所記錄的任何移動。If Not IsEmpty(Request.Form("MoveAmount") Then' 跟蹤該會話的移動數(shù)目和方向。    Session("Moves") = Session("Moves") + Request.Form("MoveAmount&quo

7、t;)   Clicks = Session("Moves")'移動到上一個已知位置。   Rst.Move CInt(Clicks)'檢查移動為 + 還是 - 并進行錯誤檢查。      If CInt(Request.Form("MoveAmount") = 1 Then         If Rst.EOF Then 

8、;           Session("Moves") = Rst.RecordCount            Rst.MoveLast         End If       

9、60;    Rst.MoveNext      End If      If Request.Form("MoveAmount") < 1 Then         Rst.MovePrevious      End If'檢查有無單擊 First Re

10、cord 或 Last Record 命令按鈕。      If Request.Form("MoveLast") = 3 Then         Rst.MoveLast         Session("Moves") = Rst.RecordCount     

11、 End If      If Request.Form("MoveFirst") = 2 Then         Rst.MoveFirst         Session("Moves") = 1      End IfEnd If'

12、對 Move Button 單擊組合進行錯誤檢查。      If Rst.EOF Then         Session("Moves") = Rst.RecordCount         Rst.MoveLast         Respon

13、se.Write "This is the Last Record"         End If            If Rst.BOF Then         Session("Moves") = 1         Rst.MoveFirst         Response.Write "This is the First Record"      End If   %><!- 顯示當前記錄數(shù)目和記錄集大小-><h3 align="center"><font f

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論