Problems inserting in sqlite and hxcpp

52 views
Skip to first unread message

Serjor

unread,
May 21, 2014, 3:21:21 AM5/21/14
to haxe...@googlegroups.com
Hello,

I'm trying to insert a field in a sqlite db, but I'm getting "null object reference" error :-(

I've been googling, and if I'm not missing something very obvious, my code is pretty close to the samples I've found.

This is the code:



package  ;

import sys.db.Connection;
import sys.db.Object;
import sys.db.Sqlite;
import sys.db.Manager;
import sys.db.TableCreate;
import sys.db.Types.SId;
import sys.db.Types;
import sys.FileSystem;
import sys.io.File;
import sys.io.FileInput;

class TMC extends Object
{
   
public var Id:SId;
   
public var Path:SString<255>;
   
public var Confemi:SInt;
   
public var Serial:SString<8>;
   
public var Transceiver1:SInt;
   
public var Transceiver2:SInt;
}
 
class TmcScanner
{
   
public function new()
   
{
       
var cnx = Sqlite.open("tmcscanner.db");
       
Manager.cnx = cnx;
       
Manager.initialize();
       
       
if (!TableCreate.exists(TMC.manager)) {
           
TableCreate.create(TMC.manager);
       
}

       
var tmc = new TMC();
        tmc
.Confemi = 10;
        tmc
.Serial = "";
        tmc
.Path = "/a/path";
        tmc
.Transceiver1 = 5;
        tmc
.Transceiver2 = 0;
        tmc
.insert();
       
       
Manager.cleanup();
        cnx
.close();
   
}
}

Any idea?


Thank you

Jason O'Neil

unread,
May 21, 2014, 3:28:32 AM5/21/14
to haxe...@googlegroups.com
Does the TMC class have

public static var manager = new Manager(TMC);

Or something similar?  That could be your null error perhaps...


--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Serjor

unread,
May 21, 2014, 4:13:16 AM5/21/14
to haxe...@googlegroups.com, he...@jasono.co
Thank you for your answer, but I didn't use it, because the documentation I've found says that is not necessary.
But I've tried your suggestion and I'm afraid that nothing changes.
I've also tried "public static var manager = new Manager<TMC>(TMC); ", but error persists.

Hugh

unread,
May 21, 2014, 4:21:55 AM5/21/14
to haxe...@googlegroups.com

If you compile with -debug, you should at least find out which object is null.


Hugh

Serjor

unread,
May 21, 2014, 5:18:27 AM5/21/14
to haxe...@googlegroups.com
According to vs2010 debugger, tmc->mPtr->manager is ok, but tmc->mPtr->sys::db::Object_obj->_manager is null.
How can I initialize it?

Thank you

Michael Bickel

unread,
May 23, 2014, 5:29:05 AM5/23/14
to haxe...@googlegroups.com
Hi there,

i stumbled across the same issue and just submitted a pull-request. 

Check it out and lemme know if you guys encounter any issues with it.


- Michael

Serjor

unread,
May 23, 2014, 12:00:06 PM5/23/14
to haxe...@googlegroups.com
Let's hope your pull request is revised and accepted.
Reply all
Reply to author
Forward
0 new messages