台灣最大程式設計社群網站
線上人數
1374
 
會員總數:246315
討論主題:189843
歡迎您免費加入會員
討論區列表 >> MS SQL >> [SQL]請問:搜尋"關鍵字"後的資料如何處理呢??
[]  
[我要回覆]
回應主題 加入我的關注話題 檢舉此篇討論 將提問者加入個人黑名單
[SQL]請問:搜尋"關鍵字"後的資料如何處理呢??
價值 : 0 QP  點閱數:2946 回應數:0
樓主

呆呆的fox
初學者
6 2
0 1
發送站內信

善心人士救命ㄚ.......
請問如何處理搜尋關鍵字後的資料,我的主程式好像沒把搜尋完畢的資料真的挑出來喔??? 
錯在rs的資料開啟吧????我猜的~~善心人士可以告訴我嗎???謝謝!!                        

以下是分頁程式<% shoeonepage---end sub%>
<%                         
  sub showOnePage(rs,page)                       
  Response.Write "<CENTER><TABLE BORDER=1><tr bgcolor=#AACOEA>"                       
                       
    ' Part I:輸出「抬頭名稱」                       
  For i=1 to rs.Fields.Count-1                       
    Response.Write "" & "<TD>" & "<font color=#800000 face=新細明體>" & rs(i).Name & "</font>" & "</TD>"                           
  Next                       
  Response.Write "</TR>"                       
  Response.Write "</font>"                       
  rs.AbsolutePage = Page                       
                         
    ' Part II:輸出資料表的「內容」                          
'  rs.MoveFirst ' 將目前資料錄移到第一筆                          
  For iPage = 1 To rs.PageSize                       
     Row = "<TR>" & "<background=back4-18.gif>"                          
     For i=1 to rs.Fields.Count-2                       
        'Response.WRITE "<TD>" & rs.Fields(i).Value & "</TD>"                       
        Row = Row & "<TD>" & "<font color=#808000 face=新細明體>" & rs(i) & "</font>" & "</TD>"                          
     Next                       
     Row = Row & "<TD>" & "<a href=/Upload/" &  rs(8) & ">" &  rs(8) & "</a></TD>"                          
     Response.Write Row & "</TR>"                          
     rs.MoveNext                       
     If rs.EOF Then Exit For                       
  Next                       
  Response.Write "</font></TABLE></CENTER>"                         
End Sub                       
%>                       

<%                           
session("SearchWords")=request.form("SearchWords")                            
session("SearchYear")=request.form("SearchYear")                              
session("SearchUp")=request.form("SearchUp")                              
session("SearchGrade")=request.form("SearchGrade")                          
session("SearchTName")=request.form("SearchTName")                         
session("SearchSubject")=request.form("SearchSubject")                        
                      
                      
If SearchWords="" then                      
SQLstr="select * from Detials where 學年度 Like'%"& session("SearchYear")&"%' and 科目 Like'%"& session("SearchSubject")&"%' and 學期 Like'%" & session("SearchUp")&"%' and 年級 Like'%" & session("SearchGrade")&"%' and 考試名稱 Like'%" & session("SearchTName")&"%' "                          
response.write "目前您正在瀏覽 "& "<font size=5 face=標楷體 color=#FF0000>" & session("SearchYear")& "</font>" & " 學年度" & "<font size=5 face=標楷體 color=#FF0000>"& session("SearchUp")& "</font>" &" 學期 " & "<font size=5 face=標楷體 color=#FF0000>" & session("SearchGrade")& "</font>" & " 年級 第" & "<font size=5 face=標楷體 color=#FF0000>"& session("SearchTName")& "</font>" & "次段考 " & "<font size=5 face=標楷體 color=#FF0000>"& SearchSubject& "</font>"  & "科 的訊息"                      
                          
    else                      
     SQLstr="select * from Detials where 科目 Like'%"& session("SearchWords")&"%' or 年級 Like'%" & session("SearchWords")&"%' or 提供者 Like'%" & session("SearchWords")&"%' or 學期 Like'%" & session("SearchWords")&"%' or 考試名稱 Like'%" & session("SearchWords")&"%' or 範圍章節 Like'%" & session("SearchWords")&"%' or 檔名 Like'%" & session("SearchWords")&"%' "                       
response.write "目前您正在瀏覽含有 「" & "<font size=5 face=標楷體 color=#FF0000>"  & session("SearchWords")& "</font>" & "」 關鍵字訊息"                      
End If                      
                      
                           
Set conn = Server.CreateObject("ADODB.Connection")                           
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("/test_paper/TP.mdb")                            
set session("conn")=conn              
set rs=server.CreateObject("ADODB.Recordset")                              
rs.open SQLstr,conn, 1, 3  'keyset, optimistic lock                        
set session("rs")=rs              
                           
if rs.EOF then                           
response.write "<center>" & "查無包含 「" & "<font size=5 face=標楷體 color=#FF0000>" & SearchWords  & "</font>" & " 」的資料,請重新查詢" & "</center>"                           
else                           
  rs.pagesize=10                     
  page=CLng(Request("Page"))                         
  if page<1 then page=1                       
  if page>rs.pagecount then page=rs.pagecount                       
                      
  showonepage rs,page                       
  response.write "<br>"                      
     if page<>1 then                        
  response.write "<a href=searchout.asp?page=1>第一頁</a>"                       
      response.write "<a href=searchout.asp?page=" & (page-1) & ">上一頁</a>"                       
  end if                       
  if page<> rs.pagecount then                        
response.write "<a href=searchout.asp?page=" & (page+1) & ">下一頁</a>"                       
response.write "<a href=searchout.asp?page=" & rs.pagecount & ">最後一頁</a>"                       
  end if                       
  response.write "<form action=searchout.asp method=get style=margin-top: 0; margin-bottom: 0> "                      
  response.write "輸入頁次:<input type=text name=page size=3> "                      
  response.write "</form> "                      
  response.write "<p style=margin-top: 0>"                     
  response.write "頁次:<FONT COLOR=Red>" & Page & "/" & rs.PageCount & "</FONT>"                      
                      
end if                           
rs.close                           
%>                           

本篇文章發表於2002-04-22 00:50
目前尚無任何回覆
   

回覆
如要回應,請先登入.