SQLite Lazarus lazarus / 16-Databases ---------------------------------------------------------------------- odvesims · 2015-06-10 14:11 Hey There!! I've recently started working with Lazarus and im having issues with SQLite. Thing is, i want to have a class (will call it DataBaseHerlper) that will manage all transactions with my DB and i want to be able to call the functions in it from other classes. I'm capable of reading/writing to the database if i do it directly on my form unit, but i dont wanna have to code it everywhere. As i mentioned before, i want to have all the methods that will deal with DB procedures in the same unit. Problem is, when i try to connect to the database via that unit, it throws a "External:SIGSEGV" error. I have no idea how to fix this. In the login form i called the method that's in my DataBaseHelper unit Code: [Select]helperDB.getCertificate(); This is the function in the DataBaseHelper unit: Code: [Select]SQLite3Connection1.DatabaseName:='PrescoTermDB.db'; SQLite3Connection1.Connected:=true; SQLTransaction1.Database:=SQLite3Connection1; SQLQuery1.Database:=SQLite3Connection1; SQLQuery1.SQL.text:='Select * FROM Certificates'; SQLQuery1.open;                                The error is thrown at the 1st line listed above. Its the "External: SIGSEGV" error. I read somewhere someone had the same error (though they were using PostgreSQL) and they fixed it by instantiating the objects (SQLite3Connection, SQLTransaction, etc) this way: Code: [Select]SQLite3Connection1:=TSQLite3Connection.Create(nil); OR Code: [Select]SQLite3Connection1:=TSQLite3Connection.Create(Application); (This requires "Forms") But that didnt work for me either. Anyone knows how can i get this to work? Im sure it's something simple, but I'm not really familiar with Pascal/Lazarus. I've done this easily in Java/Ruby/C++, Here... No luck. ---------------------------------------------------------------------- odvesims · 2015-06-10 14:31 Agh! I knew it was something rather simple. It had to do with where i placed my variables in the "DataBaseHelper" unit.. It was outside the "implementation" variables section. My bad! I guess I should do more reading about class's structures in Pascal.. ---------------------------------------------------------------------- hrayon · 2015-06-10 14:41 Hi! I don't use TSQLite3Connection, but try use full path name to ''PrescoTermDB.db'. If you will connect to db inside a method, disconnect it there, it's safest. It's usual to connect to db, share the connection while needed, and disconnect when not necessary. Perhaps this way may change the program logic in some aspects. Sorry my english.