I have a fairly simple piece of code that is creating an exception,  
and I can't understand why. This code checks a database table for the  
existence of a record with a particular field populated. The first  
time the table has no rows, so I am expecting temp to be "" in the  
example below on the first run, (because rs.RecordCount > 0 should be  
false). So I can't understand why the code is stepping into that if  
statement nor indeed why it then raises an exception.

The code is below: any help much appreciated.

  if db.Connect then
     rs = db.SQLSelect("select user.username, user.userid,  
key.userid, key.keyid, key.newkey from user,key where  
user.username='" + username +"' and user.userid=key.userid")
     if rs.RecordCount > 0 then
       while not rs.eof
         temp=rs.Field("key.newkey").Value // <-- this is where the  
NilObjectException is raised
         'next record - there shouldn't actually be one
         rs.movenext
       wend
     else
       // there was no newKey record in the table
       // so return ""
       temp = ""
     end if
     db.close
   else
     // database connection failed
     MsgBox "Sorry, there was a problem opening the database to fetch  
an account. The program has to close. [Error code 95]"
     quit
   end if


Thanks,


Ian.
--
Ian Piper
[EMAIL PROTECTED]
Key Minder : easy to use, inexpensive, industrial strength encryption  
for the rest of us : http://www.tellura.co.uk/keyminder/


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to