Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    Adelaide, Australia
    Posts
    472
    Thanks
    3
    Thanked 0 Times in 0 Posts

    No data entries than fail?

    hi,

    when you are using a SQL statement and getting records from a database,
    you use 'If NOT objRS.EOF Then'
    and because it is an 'if ... then' statement, you put an 'else' there and give it something to do if there are no records.

    how do you do this when there isn't an 'if... then' statement like
    'Do While Not objRS.EOF'

    ?

    Thanks.
    Last edited by reubenb; 02-03-2005 at 07:09 AM. Reason: spelling mistake

  • #2
    Regular Coder
    Join Date
    Oct 2004
    Location
    In front of this computer. (Where else?)
    Posts
    442
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Check this links
    If then, else
    Do While, loop
    Tomorrow is the first day of the rest of your life... What have you done today?
    Tutorials
    Web: w3schools, htmldog General tips: Hardware, Networking

  • #3
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    you could do something like an integer that increases when the loop is run, if after the "loop" line its still 0, there were no records, however i would just do

    Code:
    If NOT objRs.EOF Then
    	Do While NOT objRs.EOF
    		'...
    	objRs.MoveNext
    	Loop
    Else
    	'there were no records
    End If
    also, you dont NEED an else, and it will work without the if statement at all, this is only for if you want to get any records.. you could also check for BOF to see if the recordset exists i spose *shrugs* ive never used BOF, i dont really know what its there for

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Location
    Adelaide, Australia
    Posts
    472
    Thanks
    3
    Thanked 0 Times in 0 Posts
    That works great - thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •