Wrox Programmer Forums
|
SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 25th, 2006, 03:41 PM
Registered User
 
Join Date: Dec 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to durier
Default movenext problem

I have an application that is showing problem when i try to movenext register..
The code is the following ..

1<%Dim objConn
2Set objConn = server.CreateObject("ADODB.Connection")
3objConn.Open "cpt"
4sql = "select * from hextra where regemp=" & "'90016/0'"
5' the field data has a date where the event hextra was register
6
7sql = sql & " and month(data)=" & month(date) & " and year(data)=" & year(date) & " order by data asc"
8Set RS = objConn.Execute(sql)
9rs.movefirst
10j=1
11while (j<=30)
12 uio=rs("data")
13 uio=day(uio)
14 if j = uio then
15 response.write "<br>igual ... " & j & " - " & uio & " - " & "-->" & rs("data")
16 else
17 response.write "<br>diferente ->j=" & j & "->uio=" & uio
18 end if
19
20 'rs.movenext
21 j=j+1
22wend
23
24set rs=nothing
27set objconn=nothing
%>


In the line 20 if I uncoment this line and make a rs.movenext
to next register it give me the following answer ...

Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/urutu.asp, line 10

Any ideia what is it happen...
Thx,
 
Old January 25th, 2006, 07:19 PM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default




Hii durier!!
1>Default cursor type is forward-only
2>How do you know there are 30 items returned by the recordset??

Two ways to do
1) use connection.cursorlocation=adUseClient
totalrecord=rs.recordcount
while(j<=totalrecord)
  uio=rs("data")
'Ur actual Code Response.write
 j=j+1
 rs.movenext
wend

2>Second method is
j=1
do while not rs.eof
 uio=rs("data")
'Ur actual Code Response.write
 j=j+1
 rs.movenext
loop

3>if you want movefirst then you need dynamic/keyset/static cursor

For more information plz visit
http://www.activeserverpages.ru/ADO/dadobj01_6.htm
http://authors.aspalliance.com/aspxt...recordset.aspx

Hope this will help you

Cheers :)

vinod
 
Old January 25th, 2006, 10:49 PM
Registered User
 
Join Date: Dec 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to durier
Default


vinod,
Thanks for reply back...

I changed the code as you suggest as following ... but same problem happen ..for some crazy reason my problem is get the next record..on the rs.movenext

<%
set rs = CreateObject("ADODB.Recordset")
sql = "select * from hextra where regemp=" & "'1234'"
sql = sql & " and month(data)=" & month(date) & " and year(data)=" & year(date) & " order by data asc"
rs.Open sql,"DSN=cpt",1,3
'on error resume next
do while j <= 30

     uio=day(rs("data"))

         response.write "<br>" & uio & " - "
         response.write j
         k=uio-j
     if k=0 then
          response.write "<br>igual ... " '& j & " - " & uio & " - " & "-->" & rs("data")
     else
          response.write "<br>diferente ->j=" & j & "->uio=" & uio
     end if

     rs.movenext
     j=j+1
loop

set rs=nothing
set objconn=nothing
%>

it is give me ...
Technical Information (for support personnel)

Error Type:
(0x80020009)
Exception occurred.
/URUTU.ASP, line 9

if I comment the movenext it run but not get the next register(as expected) but if i use the movenext it give the exception...
some fact about the environment is I am using Mysql and the field data is a datetime type ... I was think about some cast problem but as you see it is being saw as interger once i be able to search for 0 result if equal ...

it is the result if i comment the movenext ...

.
.

diferente ->j=16->uio=18
18 - 17
diferente ->j=17->uio=18
18 - 18
igual ...
18 - 19
diferente ->j=19->uio=18
18 - 20
diferente ->j=20->uio=18
.
.
.

Thanks again for your help and support.
Brgds,
Fernando Durier


Quote:
quote:Originally posted by durier
 I have an application that is showing problem when i try to movenext register..
The code is the following ..

1<%Dim objConn
2Set objConn = server.CreateObject("ADODB.Connection")
3objConn.Open "cpt"
4sql = "select * from hextra where regemp=" & "'90016/0'"
5' the field data has a date where the event hextra was register
6
7sql = sql & " and month(data)=" & month(date) & " and year(data)=" & year(date) & " order by data asc"
8Set RS = objConn.Execute(sql)
9rs.movefirst
10j=1
11while (j<=30)
12 uio=rs("data")
13 uio=day(uio)
14 if j = uio then
15 response.write "<br>igual ... " & j & " - " & uio & " - " & "-->" & rs("data")
16 else
17 response.write "<br>diferente ->j=" & j & "->uio=" & uio
18 end if
19
20 'rs.movenext
21 j=j+1
22wend
23
24set rs=nothing
27set objconn=nothing
%>


In the line 20 if I uncoment this line and make a rs.movenext
to next register it give me the following answer ...

Error Type:
ADODB.Field (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/urutu.asp, line 10

Any ideia what is it happen...
Thx,

 
Old January 27th, 2006, 03:03 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 553
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to vinod_yadav1919 Send a message via Yahoo to vinod_yadav1919
Default

Hii durier!!
<%
set rs = CreateObject("ADODB.Recordset")
sql = "select * from hextra where regemp=" & "'1234'"
sql = sql & " and month(data)=" & month(date) & " and year(data)=" & year(date) & " order by data asc"
rs.Open sql,"DSN=cpt",1,3
j=1

do while not (rs.eof and j <= 30)

     uio=day(rs("data"))

         response.write "<br>" & uio & " - "
         response.write j
         k=uio-j
     if k=0 then
          response.write "<br>igual ... " '& j & " - " & uio & " - " & "-->" & rs("data")
     else
          response.write "<br>diferente ->j=" & j & "->uio=" & uio
     end if

     rs.movenext
     j=j+1
loop

set rs=nothing
set objconn=nothing
%>

Hope this will help you

Cheers :)

vinod
 
Old January 27th, 2006, 08:04 AM
Registered User
 
Join Date: Dec 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to durier
Default

VINOD,
THANKS FOR HELP...
I FOUND THE PROBLEM, THERE IS A LOOP OF J FROM 0 TO 31 AND IT HAS TO DO WITH DAYS OF MONTH, THERE ARE SOME EVENTS THAT MAY BE PRESENT OR NOT BY DAY AND IT IS RETURNED ON THE RECORD SET FROM THE TABLE HEXTRA, THE FACT IS THAT I DO NOT KNOW IF EXIST AND WHEN I HAVE JUST 2 RECORDS ON THE RECORDSET AND TRY TO DO MOVENEXT IF THE EOF OR BOF IS TRUE IT WAS GIVE ME THE EXCEPTION, SO I JUST CHECK ...
IF NOT RS.EOF THEN
 RS.MOVENEXT
END IF
IT IS WORKING NOW ... THANK YOU VERY MUCH FOR YOU TIME AND SUPPORT.
bRGDS,
FERNANDO






Similar Threads
Thread Thread Starter Forum Replies Last Post
Movenext with ado.net rwalker ASP.NET 1.0 and 1.1 Professional 2 February 20th, 2010 06:21 AM
rs.MoveNext loops the page myhomor ASP.NET 1.0 and 1.1 Basics 2 January 14th, 2008 01:03 PM
2 small problems, maybe movenext placement? aduggan Classic ASP Databases 1 April 24th, 2007 12:28 PM
iteration movenext weazy Excel VBA 0 June 9th, 2006 05:56 PM
rs.movenext problem hastikeyvan Dreamweaver (all versions) 1 October 27th, 2005 10:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.