|
出来るのだASP Q&A掲示板(過去LOG)
訪問数 52046
昨日 889
今日 776 【PR】 パソコン入門からIT専門書まで幅広く取り揃えています。セブン-イレブン受取り手数料無料のセブンアンドワイ。 |
Topに戻る
掲示板に戻る
検索
削除
管理者
|
| [714] ASPの検索結果ページ表示について |
| 投稿者:yuriさん 2001/10/12 16:02:33 |
| こんにちは いつも参考にさせて頂いています。 ASPをはじめてまだ数日の初心者です。 毎日、本とサンプルコードとにらめっこしてますが、質問があります。 300件以上のデータの中から、条件設定をして検索をします。 結果は10件づつ表示して、他のページに飛べるようにします。 いくつかのサンプルと入門書を参考に、検索して10件づつ表示して、全体ページ数と 今のページが表示できましたが、他のページに飛ぼうとしてもエラーになります。 どこを直したらちゃんと表示できますか? ヒントだけでもいいので教えてください。 スクリプトは下記のようにしています。 (別のファイルで、検索条件を設定してこちらのaspファイルで結果表示。) <html> <head> <title>検 索 結 果</title> <base target="_self"> </head> <body> <% Dim ObjConn,ObjRS, Set ObjConn = Server.CreateObject("ADODB.Connection") Dim key_kouysu ObjConn.Open "jirei" '検索ワードを取得 '工種が選択してあれば、それを検索条件とする If Request.Form("kousyu") = "指定しない" Then Set ObjRS = Server.CreateObject("ADODB.Recordset") SQL = "SELECT * FROM [jirei]" ObjRS.Open SQL,ObjConn,3,2 Else Set key_kousyu=Request.Form("kousyu") Set ObjRS = Server.CreateObject("ADODB.Recordset") SQL = "SELECT * FROM [jirei] WHERE((jirei.工種) = '"& key_kousyu &"')" ObjRS.Open SQL,ObjConn,3,2 End If %> <b>工種:</b><%= Request.Form("kousyu") %>で検索しました<BR> 検索結果 <% Dim PageNum 'もし、該当データがなければこの表示 If ObjRS.Eof Then Response.Write "<center><font size=3 color=#FF0000><b>該当するデータはありません。</b></font></center>" Else '該当データがあれば、1ページのレコード数を10件に ObjRS.PageSize = 10 Page=ObjRS.PageCount for i=1 to ObjRS.PageCount Response.Write"[ <A href=jirei_main.asp?page="&i&">"&i&"</A> ]" next PageNum=CInt(Request.QueryString("page")) if PageNum<1 or PageNum> ObjRS.PageCount then PageNum=1 end if ObjRS.AbsolutePage = PageNum Response.Write"<P>page:"& PageNum &"/" & ObjRS.PageCount & "</p>" Response.Write ObjRS.RecordCount & "件のデータがみつかりました。" & "<BR>" '項目を表示する Response.Write "<div align=center>" Response.Write "<center>" Response.Write "<table border=1 bordercolor='blue' cellspacing=0 width= 700>" Response.Write "<tr>" Response.Write "<td align=center height=30 bgcolor=#0000CE width=300><font size=2 color=#FFFFFF><b>タイトル</b></font></td>" Response.Write "<td align=center height=30 bgcolor=#0000CE width=70><font size=2 color=#FFFFFF><b>工種</b></font></td>" Response.Write "<td align=center height=30 bgcolor=#0000CE width=100><font size=2 color=#FFFFFF><b>種別</b></font></td>" Response.Write "<td align=center height=30 bgcolor=#0000CE width=90><font size=2 color=#FFFFFF><b>事故の型</b></font></td>" Response.Write "<td align=center height=30 bgcolor=#0000CE width=70><font size=2 color=#FFFFFF><b>起因</b></font></td>" Response.Write "<td align=center height=30 bgcolor=#0000CE width=70><font size=2 color=#FFFFFF><b>PDFファイル名</b></font></td>" Response.Write "</tr>" 'ページサイズの数だけデータを表示する for j=1 to ObjRS.PageSize X1=objRS.Fields("タイトル") X2=objRS.Fields("工種") X3=objRS.Fields("種別") X4=objRS.Fields("事故の型") X5=objRS.Fields("起因") X6=objRS.Fields("PDF_FILE") Response.Write "<tr>" Response.Write "<td><font size=2>" & X1 & "</font></font></td>" Response.Write "<td><font size=2>" & X2 & "</font></font></td>" Response.Write "<td><font size=2>" & X3 & "</font></font></td>" Response.Write "<td><font size=2>" & X4 & "</font></font></td>" Response.Write "<td><font size=2>" & X5 & "</font></font></td>" Response.Write "<td><font size=2>" & X6 & "</font></font></td>" Response.Write "</tr>" ObjRS.MoveNext if ObjRS.EOF then exit for next Response.Write "</table>" Response.Write "</center>" Response.Write "</div>" End If ObjRS.Close %> </body> </html> **********というわけなんですが、どこか根本的に間違っているのでしょうか? 初歩的なことで恐縮ですが、よろしくお願いします。 |
![]()
ASPの検索結果ページ表示について
yuriさん
[2001/10/12 16:02:33]
[714]
|
Re:ASPの検索結果ページ表示について
Tomitomiさん
[2001/10/12 16:12:59]
[715]
Re:ASPの検索結果ページ表示について
yuriさん
[2001/10/12 17:45:42]
[716]
Re:ASPの検索結果ページ表示について
Tomitomiさん
[2001/10/12 18:39:21]
[717]
Re:ASPの検索結果ページ表示について
yuriさん
[2001/10/12 21:55:07]
[720]
Re:ASPの検索結果ページ表示について
北岳さん
[2001/10/13 14:13:44]
[722]
Re:ASPの検索結果ページ表示について
北岳さん
[2001/10/13 14:27:32]
[723]
|
|
TreeBBS For ASP V.0.1.3 |