国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

實驗Recordset.Movenext,Recordset.Previous,Recorset...等移動記錄

2019-11-18 22:39:29
字體:
來源:轉載
供稿:網友
我在實驗Recordset.Movenext,Recordset.PRevious,Recorset.......等移動記錄的時候遇到了困難.
我用access做后臺數據庫,通過一個查詢條件查詢得一個記錄集,我想用一個表格實現記錄的逐條瀏覽(不是一組記錄分頁瀏覽). 即"共查到**條記錄,現在是第*條",單擊"Next"按鈕后下一條記錄的內容顯示在表格中.....

我用如下代碼實現(見最后)

發現若將Rst.Open "select * from 某表 where 從某個Form獲取的查詢條件"
改成  Rst.Open "select * from 某表"(相當于不做查詢動作)后, 記錄的瀏覽功能才得以實現.
否則總是出現" EOF或BOF為真 "的錯誤提示.可我明明可以從"某表"中 "select... where..."到好幾個記錄的!

總之如何將"記錄的逐條瀏覽"和"select * from 某表 where 從某個Form獲取的查詢條件" 結合起來?

望予以指點為感!

楊利
2000/4/13

程序代碼:

<%@ LANGUAGE=VBScript %>
<!-- #Include file="ADOVBS.INC" -->
<html>
<head>
<title></title>
</head>
<body BGCOLOR="#FFFFF0">
<h3 align="center"><font face="隸書" color="#004080"><big>現在您可以編輯以下記錄</big></font></h3>
<!-- 在服務器上創建 Connection 和 Recordset 對象 -->
<%
'創建并打開 Connection 對象。
Set cn=Server.CreateObject("ADODB.Connection")
    cn.Open "DSN=數據庫名"
'創建并打開 Recordset 對象。
Set Rst = Server.CreateObject("ADODB.Recordset")
    Rst.ActiveConnection = cn
    Rst.CursorType = adOpenKeyset
    Rst.LockType = adLockOptimistic   
Rst.Open "select * from 某表 where 性別='"&request.form("t1")&"'"(執行這句大有問題)
Rst.Open "select * from 某表 where 性別='男'"(執行這句有點問題)
Rst.Open "select * from hr_base"(執行這句沒有問題)
' 檢查 Request.Form 集合以查看所記錄的任何移動。
If Not IsEmpty(Request.Form("MoveAmount")) Then
' 跟蹤該會話的移動數目和方向。
   session("Moves") = Session("Moves") + Request.Form("MoveAmount")
   Clicks = Session("Moves")
'移動到上一個已知位置。
   Rst.Move CInt(Clicks)
'檢查移動為 + 還是 - 并進行錯誤檢查。
      If CInt(Request.Form("MoveAmount")) = 1 Then
         If Rst.EOF Then
            Session("Moves") = Rst.RecordCount
            Rst.MoveLast
         End If   
         Rst.MoveNext
      End If
      If Request.Form("MoveAmount") < 1 Then
         Rst.MovePrevious
      End If
'檢查有無單擊 First Record 或 Last Record 命令按鈕。
      If Request.Form("MoveLast") = 3 Then
         Rst.MoveLast
         Session("Moves") = Rst.RecordCount
      End If
      If Request.Form("MoveFirst") = 2 Then
         Rst.MoveFirst
         Session("Moves") = 1
      End If
End If
' 對 Move Button 單擊組合進行錯誤檢查。
      If Rst.EOF Then
         Session("Moves") = Rst.RecordCount
         Rst.MoveLast
         Response.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
   %>
<!-- 顯示當前記錄數目和記錄集大小-->
<h3 align="center"><font face="隸書" color="#004080">共查到</font><font color="#600060"><%=Rst.RecordCount%></font><font face="隸書" color="#004080">條記錄,當前為第</font>
<font color="#600060">
<%
If IsEmpty(Session("Moves"))  Then
           Session("Moves") =1
End If
%>
<%Response.Write(Session("Moves") )%>
</font><font face="隸書" color="#004080">條記錄</font></h3>
<hr align="center">
<p align="center">  <input Type="button" Name="cmdFirst" Value="第一條"                                     
style="font-family: 宋體"><input Type="button" Name="cmdDown" Value="上一條"><input                                     
Type="button" Name="cmdUp" Value="下一條"><input Type="button" Name="cmdLast"                                     
Value="末一條"> </p>                                                                     
<p align="center"><b><font size="5" color="#000080" face="隸書">查詢結果:</font></b></p>                                        
                                        
<table>
(用于逐條顯示記錄的表格)                                       
</table>   
                                    
<!-- 使用隱含窗體字段將值發送到服務器-->                                                                       
<form Method="Post" Action Name="Form">                                    
  <input type="hidden" name="MoveAmount" value="0"><input type="hidden" name="MoveLast"                                    
  value="0"><input type="hidden" name="MoveFirst" value="0">                                    
</form>                                    
</body>                                    
<script Language="VBScript">                                                                        
Sub cmdDown_OnClick                                    
'在 Input Boxes 窗體和 Submit 窗體中設置值。                                                                 
   Document.Form.MoveAmount.Value = -1                                    
   Document.Form.Submit                                    
End Sub                                                                       
Sub cmdUp_OnClick                                                                        
   Document.Form.MoveAmount.Value = 1                                    
   Document.Form.Submit                                    
End Sub                                                                        
Sub cmdFirst_OnClick                                                                       
   Document.Form.MoveFirst.Value = 2   Document.Form.Submit                                      
End Sub                                                                        
Sub cmdLast_OnClick                                                                        
   Document.Form.MoveLast.Value =3                                    
   Document.Form.Submit                                    
End Sub                                    
</script>                                                            
</html> 
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 改则县| 颍上县| 绍兴市| 泽普县| 新昌县| 星子县| 宜兰市| 昌平区| 会泽县| 呈贡县| 鹤山市| 汝南县| 通海县| 海晏县| 伊川县| 郸城县| 石屏县| 平江县| 新化县| 新泰市| 驻马店市| 扎鲁特旗| 遵化市| 彭州市| 金坛市| 岑巩县| 新沂市| 永定县| 东乌珠穆沁旗| 咸宁市| 岳普湖县| 溧水县| 孝义市| 无锡市| 游戏| 浦北县| 安仁县| 丹寨县| 潞西市| 子长县| 天祝|