Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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 July 17th, 2003, 05:25 PM
Authorized User
 
Join Date: Jul 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default why don't i see all my values?

**i have 3 records in a database

itemNumber=113344, paymentStatus=Completed
itemNumber=114455, paymentStatus=Completed
itemNumber=115566, paymentStatus=Completed

**this code (below) should loop through all of these records and present a value of either true or false

rs.movefirst
do while not rs.eof

itemNumberGet=rs("itemNumber")
paymentStatusGet=rs("paymentStatus")

if itemNumberGet = "113344" and paymentStatusGet = "Completed" then
test=True

else
test=False

end if

rs.movenext
loop

**then it does one thing or another based on the value true or false

if test=True then
elseif test=False then
end if


**this code snippet is in place 4 times in my asp page. if i comment out the rs.movefirst in my fourth code element, i get all my data,if i leave it in so all of the code snippets are exactly the same, i don't get my last dataset and the value is false when it should be true even though i absolutely have this set of data present. does anybody see any problem in this code? i would really appreciate any insight. i've had to modify my looping code numerous times trying to get this to work and i am about to go crazy...thanks.

 
Old July 18th, 2003, 02:13 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Question: Is the field itemNumber a numeric value or a string value?

Your line of code:
if itemNumberGet = "113344" and paymentStatusGet = "Completed" then

seems to imply that it is a character string "113344" and not the number 113344.



 
Old July 18th, 2003, 06:52 AM
Authorized User
 
Join Date: Jul 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i'll try that but i have my data type set to text so i believe it is a string value. thank you for the suggestion. i'll try anything at this point.

 
Old July 18th, 2003, 07:10 AM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think I see you problem. The way your loop is now, if the record you are looking for is the first one, test will be true. But since you don't stop your loop, test will be affected to false with the next record.

Try changing your code to this:

Code:
' Initialize test to False
test = False
rs.movefirst
do while not rs.eof

    itemNumberGet=rs("itemNumber")
    paymentStatusGet=rs("paymentStatus") 

    if itemNumberGet = "113344" and paymentStatusGet = "Completed" then
        test=True
        'You fond the record you a looking for, no need to continue the loop
        Exit Do
    end if

    rs.movenext
loop

**then it does one thing or another based on the value true or false

' You don't need to check if test = false
if test=True then
else
end if
Stéphane Lajoie
 
Old July 18th, 2003, 09:22 AM
Authorized User
 
Join Date: Jul 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you so much stephane. that solves just about everything. now i just need to set the logic for no records in the database. with your solution i can't imagine this would be too hard now that you've gotten me to this point. i have this code before my first asp block...

if rs.bof and rs.eof=True then
test=False
end if

but as soon as the code reads rs.movefirst and there are no records in the database, i get an error saying the operation requires a current record. i'm taking a break then i will return to solve this. again, thank you so much.

 
Old July 18th, 2003, 09:39 AM
Authorized User
 
Join Date: Jun 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Then try this variation, it should correct the no record problem.
Code:
' Initialize test to False
test = False
if rs.eof then
    rs.movefirst
    ' Test the rs.eof at the end of loop since there is at lease one record
    do

        itemNumberGet=rs("itemNumber")
        paymentStatusGet=rs("paymentStatus") 

        if itemNumberGet = "113344" and paymentStatusGet = "Completed" then
            test=True
            'You fond the record you a looking for, no need to continue the loop
            Exit Do
        end if

        rs.movenext
    loop while not rs.eof
end if

**then it does one thing or another based on the value true or false

' You don't need to check if test = false
if test=True then
else
end if
Stéphane Lajoie
 
Old July 18th, 2003, 11:44 AM
Authorized User
 
Join Date: Jul 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Default

interesting. in this version i get the value of false regardless. i'll try modifications of your code...






Similar Threads
Thread Thread Starter Forum Replies Last Post
get the values of form field values crmpicco Perl 2 March 16th, 2007 10:57 AM
Get Values from Checkboxlist derekl ASP.NET 1.0 and 1.1 Basics 3 May 26th, 2006 09:46 AM
Using Values from a ListBox timmaher Classic ASP Databases 2 September 14th, 2005 10:01 AM
Where have all the values gone? clandestine XML 1 June 29th, 2005 10:10 AM
loop values and text box values move mateenmohd Classic ASP Basics 2 April 5th, 2005 11:33 PM





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