Database Problem

I am trying to delete a database using the following code.

[code] dim result as integer

result = msgbox (“Are You Sure you want to DELETE the DATABASE ?”,36)
if result=6 then
golfer.close ******** PROBLEM HERE
Dim f as Folderitem
f=SpecialFolder.ApplicationData.Child(“TGC”).Child(“Golf”).Child(“golfer.rsd”)
f.Delete()
If f.LastErrorCode > 0 then
MsgBox Str(f.LastErrorCode)
Else
MsgBox “DataBase Deleted, Program must be Restarted to Create NEW Database”
window.close
End if
exit
end if[/code]

I keep getting the following, the file golfer.rsd Does exist in the correct Directory

NilObjectException
F Nil
Me Bevelbutton
Result 6

A nil object exception normally means that the object has not been initialised. I suspect that the database variable golfer has not been set prior to the call to delete the actual file.

Put a break point on the offending line and see what the object inspector says at runtime. Report that back here.

if you are having a problem with golfer.close it is probably because it is not in scope. I am assuming golfer.rsd is a RealSQLDatabase and you must have instantiated it somewhere as golfer, either in the window or in the app. Use app.golfer. if it is a property of the app.

Thanks Dean app.golfer.close fixed the problem.