Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Recordset

Status
Not open for further replies.

murugesanks

Programmer
Jan 25, 2001
48
US
Mr. Harold Blackorby,


Actually i am trying to display 5 records in a page and giving link to other pages like,

25 Records found.

(1-5) (6-10) (11-15) (16-20) (21-25)

Page 1
---------------------
1.First Record.

2. Second record

3. Third Record

4. Fourth Record.

5. Fifth Record.
---------------------

When I click (6-10) link It should display Next 5 records,…..


For the above I tried like.
<%
DIM currentPage, rowCount, i
currentPage = TRIM( Request( &quot;currentPage&quot; ) )
if currentPage = &quot;&quot; then currentPage = 1
set DBConn = server.createobject(&quot;adodb.connection&quot;)
DBConn.open &quot;dsn=portdsn;uid=sa;pwd=;database=PortDB&quot;
Set MemDisRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
MemDisRS.CursorType = adOpenStatic
MemDisRS.PageSize = 5
MemDisRS.Open &quot;select * from table1 order by no&quot;, DBConn
Response.write &quot;Current Page Value is :&quot;
Response.write currentPage
Response.Write &quot;<br><br>&quot;
MemDisRS.AbsolutePage = cINT( currentPage )
rowCount = 0
x1=&quot;hi&quot;
While not MemDisRS.EOF and rowCount < MemDisRS.PageSize
Response.Write MemDisRS(0)
Response.Write &quot;<br>&quot;
rowCount = rowCount + 1
MemDisRS.MoveNext
Wend
Response.Write &quot;<hr>&quot;
for i = 1 to MemDisRS.PageCount
%><a href=&quot;TradersDisplayTest1.asp?currentPage=<%=i%>&quot;><%=i%></a> <%
next
%>


It is giving the following Error.

--
ADODB.Recordset error '800a0cb3'
Object or provider is not capable of performing requested operation.
Tradersdiaplaytest1.asp line 18.
--

Line no 18 is:

MemDisRS.AbsolutePage = cINT( currentPage )

I think MemDisRS.AbsolutePage is giving error. Because I tried to display the Recordscount. But it is returning -1(minus one). But in Database 25 recirds are there.
 
I have encountered this error before with a recordcount displaying negative records. To be honest, I am not sure why it is doing this at all. At the time, I just used a j variable to count the records myself, although I know this is a clumsy way to do it, it worked on the project I was on.

If anyone else can help with why recordset.recordcount returns negative values sometimes, please post to this thread. I think it would be of help to both of us. Harold Blackorby
hblackorby@scoreinteractive.com
St. Louis, MO
 
I have actually just been through the same thing using a paging script and a recordcount command on the same page. It displayed a negative value at first under recordcount but seemed to sort itself out when I added a WHERE clause to the SQL query. To be honest I am not actually sure why this fixed it but it did.

Not much help I know but maybe somebody else knows some more than me....


Justin.X-) &quot;Creativity is the ability to introduce order into the randomness of nature.&quot; Eric Hoffer

Visit me at
 
Try adding
DBConn.CursorLocation = 3 'adUseClient
after you set the connection object but before you open it. This should at least correct the problem with the recordcount not returning properly.
 
Yes,
I got the result.
I adding added this line
--
DBConn.CursorLocation = 3 'adUseClient
--
this is given by RealQuiet.

Thanks.
Murugesan.
 
I'm a little late on this posting, but -1 usually means no reords in the recordset. It all depends on, as you found out, the cursortype and recordset type used.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top