NilObjectException problem in Xojo

85 views
Skip to first unread message

chris Benton

unread,
Oct 12, 2013, 8:11:59 AM10/12/13
to realstudio...@googlegroups.com
Hi Guys,
I finally jumped from VB6 to RealStudio a year ago and then to Xojo when it was released. I am finding out that 25 years of VB has not done much for my programming skills except make me depend on VB to clean up my bad habits. I am attempting to set up communications with a pre-existing database using a small program  to demonstrate that I can read and write to the sqllite database engine provided by Xojo. I have a method placed in a module that connects a global variable called 'DB' with a database. It can be called  by using a method called SetDB the database name is passed using a variable called DBname as a string. Below is the offending snippet;

Sub SetDB(dbname as string)
  
  msgbox dbname
  db.DatabaseName=dbname
  
  
  
  if db.Connect=false then
    msgbox "couldnt connect with the database"
    quit
  end if
End Sub 


Everytime the program hits  db.DatabaseName=str(dbname) the program halts with a NilObjectException. I test to see of the DBname is being passed correctly by using a message box and all is well until it hits the  db.DatabaseName=dbname line.
The calling piece of code is SetDB "testdb.sqllite", The program attempts to execute the method and passes the name of the database, but for the life of me, I cant figure out why this exception is being raised.
I dont want to put my Mac on ebay with "serious hammer damage", but If I cant solve what seems to be a most basic problem, then it will get nasty.
Any help will be most appreciated.
Chris

Mark Davis

unread,
Oct 12, 2013, 8:55:49 AM10/12/13
to realstudio...@googlegroups.com
Hi ya,

sqlite .. looking at the doco, i'm not 100% sure it implements Databasename http://docs.xojo.com/index.php/SQLiteDatabase
that property seems to be for "server" databases like mysql/postgresql and what not but sqlite is a "file" database and uses DatabaseFile method instead.

Otherwise, I think you might have missed initialising "db" for the db.Databasename setting

- Mark



--
You received this message because you are subscribed to the Google Groups "RealStudio Sydney UG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to realstudio-sydne...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

chris Benton

unread,
Oct 13, 2013, 1:27:31 AM10/13/13
to realstudio...@googlegroups.com

Hi Mark,
Thanks for having a crack at the problem.
DatabaseName is implemented within the Database class and wont compile at runtime if its illegal.
The DB name has been setup as a module property, so I know that its available globally. I even tried dimensioning it locally at the method, but this doesnt help.
Going to mitre10 now to get a very large sledgehammer.
Chris 
To unsubscribe from this group and stop receiving emails from it, send an email to realstudio-sydney-ug+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages