Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Sat Dec 15, 2018 2:11 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: nil value for REALSQLDatabase
PostPosted: Sat Mar 23, 2013 9:08 pm 
Offline
User avatar

Joined: Fri Oct 10, 2008 7:14 pm
Posts: 94
I have the following code in in a Method of a GlobalModule. The subroutine is executed immediately when the app is opened.
..................
dim sSQL As String
dim rsTW as RecordSet
dim dbTW as new REALSQLDatabase

dbTW.databaseFile = getFolderItem("").child("Database").child( "TimeWorked.rsd" )

if dbTW.databaseFile.exists then
if not dbTW.connect() then
MsgBox("Database Connection Error")
gDBError = "Y"
return
end
else // dbTW was not found
MsgBox("Database Not Found")
gDBError = "Y"
return
end

rsTW = dbTW.SQLSelect("SELECT * FROM Admin")

return
..........................
Debugging/Tracing indicates that it runs properly.

I have a global property defined in the GlobalModule: dbTW as REALSQLDatabase

In any other module, when I try to use dbTW, an examination of Global Variables show dbTW with a value of nil.

Am I missing something basic.

thanks,
b


Top
 Profile  
Reply with quote  
 Post subject: Re: nil value for REALSQLDatabase
PostPosted: Sat Mar 23, 2013 9:12 pm 
Offline
User avatar

Joined: Fri Oct 10, 2008 7:14 pm
Posts: 94
Just realized I had the dim dbTW in the subroutine. When I took it out I get the nil error in the initial global module.


Top
 Profile  
Reply with quote  
 Post subject: Re: nil value for REALSQLDatabase
PostPosted: Sun Mar 24, 2013 12:07 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Don't just take it out. Replace it with

dbTW = New REALSQLdatabase

You have to instantiate the object before you can use it.


Top
 Profile  
Reply with quote  
 Post subject: Re: nil value for REALSQLDatabase
PostPosted: Mon Mar 25, 2013 9:20 am 
Offline
User avatar

Joined: Fri Oct 10, 2008 7:14 pm
Posts: 94
Thanks much Tim, definitely was the problem.

b


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group