出来るのだASP Q&A掲示板(過去LOG)  訪問数 52046 昨日 889 今日 776
    【PR】 パソコン入門からIT専門書まで幅広く取り揃えています。セブン-イレブン受取り手数料無料のセブンアンドワイ。
Topに戻る 掲示板に戻る 検索 削除 管理者

[1595] Re:onFocusイベント処理について
投稿者:はりさん 2002/02/04 15:44:12
Tomitomiさん解答ありがとうございます。

もう一つ質問をしてもよろしいでしょうか?

今 これと同時にASP&ADOを使ってレコードセットのページングをしようと思っています。

MicroSoftに載っていたものを変更しようと思ったのですが・・・

<%@language="vbscript" %>
<% Option Explicit%>
<%
dim iPageNum,iRowsPerPage

Main 'MAIN関数を呼んでいる

sub Main()
dim rst
dim ssql

if Request.QueryString("iPageNum") = "" then
iPageNum = 1
else
iPageNum = Request.QueryString("iPageNum")
iPageNum = cint(iPageNum)
end if

iRowsPerPage = 2

ssql = "select * from M_bbs"

set rst = getRecord(objcon,ssql)

writetableheadder rst
writetablebody rst,iRowsPerPage,iPageNum
showNavBar rst

cleanup rst
end sub

function getRecord(objcon,ssql)
dim rst

objcon.open session("connectionstring")

set rst = server.CreateObject("ADODB.recordset")
set rst.ActiveConnection = objcon

rst.CursorLocation = aduseserver

'型は、Long型
'rst.CacheSize = clng(iRowsPerPage)

rst.Open ssql,,adOpenDynamic,adLockReadOnly

set getRecord = rst
end function

sub writetableheadder(rst)
dim fld

Response.Write "<table width='80%' border=1>"
Response.Write "<tr>"

'表の列見出しを作成します
for each fld in rst.Fields
Response.Write "<td><b>" & fld.name & "</b></td>"
next
Response.Write "</tr>"
end sub

sub writetablebody(rst,iRowsPerPage,iPageNum)
dim iloop
dim fld

iloop = 1

rst.PageSize = iRowsPerPage
'rst.AbsolutePage = iPageNum

'現在のレコードページを書き出します
do while (not rst.EOF) and (iloop <= iRowsPerPage)
Response.Write "<tr>"
for each fld in rst.Fields
Response.Write "<td>" & fld.value & "</td>"
next

iloop = iloop + 1
rst.MoveNext
Response.Write "</tr>"
loop
Response.Write "</table>"
end sub

sub ShowNavBar(rst)
dim iPageCount
dim iloop
dim sScriptName

Response.Write "<br><br>"
sScriptName = Request.ServerVariables("SCRIPT_NAME")

if iPageNum > 1 then
Response.Write "<a href=" & sScriptName & "?iPageNum="
Response.Write (iPageNum - 1) & "><< Previous</a>"
end if

iPageCount = rst.PageCount
do until iloop > iPageCount
if iloop = iPageCount then
Response.Write " <b>" & cstr(iloop) & "</b>"
else
Response.Write " <a href=" & sScriptName & "?iPageNum=" & _
cstr(iloop) & ">" & iloop & "</a>"
end if
iloop = iloop + 1
loop

if not rst.EOF then
Response.Write " <a href=" & sScriptname & "?iPageNum="
Response.Write (iPageNum + 1) & "> Next >></a><br>"
else
Response.write "<br>"
end if

Response.Write "Page " & iPageNum & " of " & iPageCount & "<br>"
Response.Write rst.RecordCount & " Records"
end sub

sub cleanup(rst)
if not rst is nothing then
if rst.State = adstateopen then rst.Close
set rst = nothing
end if
objcon.close
end sub
%>
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=x-sjis">
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE>ASPからのレコードをページングする(ShowNavBarn)</TITLE>
</HEAD>
<BODY>
</BODY>
</HTML>

一応、Global.asaの中でADOのTypeLibの宣言はしています。
(msado15.dll)を参照しています。
ただし、これを実行すると

「エラー タイプ
   ADODB.Recordset (0x800A0BB9)
   引数が間違った型、許容範囲外、または競合しています。
   /mypage/pagecount.asp, line 43」
と表示されてしまいます。 あとレコードセットのカウントもなぜかとれず絶えず、「-1」と表示されてしまいます。これは一体どういった原因からなのですか? よろしければ アドバイスの方お願いします。



onFocusイベント処理について   はりさん [2002/02/04 14:02:08] [1593]
  Re:onFocusイベント処理について   Tomitomiさん [2002/02/04 14:41:32] [1594]
    Re:onFocusイベント処理について   はりさん [2002/02/04 15:44:12] [1595]
      Re:onFocusイベント処理について   Tomitomiさん [2002/02/04 16:31:02] [1597]
        Re:onFocusイベント処理について   はりさん [2002/02/04 17:46:31] [1598]
  Re:onFocusイベント処理について   喜平さん [2002/02/04 22:26:42] [1600]


TreeBBS For ASP V.0.1.3
Program By YasNet