Lazarus
Programming => Databases => Topic started by: cov on April 10, 2013, 10:23:38 pm
-
I'm getting SIGSEGV errors on my firebird Database.
with IBConnection1 do
begin
DatabaseName:='localhost:'+dbpath+PathDelim+dbname+'.fdb';
UserName:='sysdba';
Password:='myp4ssw0rd';
end;
SQLQuery1.Close;
SQLQuery1.SQL.Text:='SELECT '+QFields+' FROM FIELDS'+QFilter+Qsort;
SQLQuery1.ExecSQL;
IBConnection1.Connected:=True;
SQLTransaction1.Active:=True;
SQLQuery1.Open;<- SIGSEGV occurs here.
Can anyone suggest anything to try?
-
You seam to be trying to execute a select query before connecting to the database. Remove the SQLQuery1.ExecSQL;
The database may be returning a error which is not being caught. Use a try except block around the SQLQuery1.Open;.
-
try commenting out these lines !!
SQLQuery1.ExecSQL;
IBConnection1.Connected:=True;
SQLTransaction1.Active:=True;
-
I wouldn't disable the transaction stuff. Spelling things out can be good ;)
You'd get something like this:
with IBConnection1 do
begin DatabaseName:='localhost:'+dbpath+PathDelim+dbname+'.fdb';
UserName:='sysdba';
Password:='myp4ssw0rd';
end;
// open database connection and transaction first. The query should be linked to the transaction
IBConnection1.Connected:=True;
SQLTransaction1.Active:=True;
// you must have linked sqlquery1 to the database/transaction somewher - probably in the GUI/object inspector?
SQLQuery1.Close;
SQLQuery1.SQL.Text:='SELECT '+QFields+' FROM FIELDS'+QFilter+Qsort;
//SQLQuery1.ExecSQL; // open and execsql are mutually exclusive. Use open for getting results, use execute if you don't want or expect results.
SQLQuery1.Open;
-
See:
http://wiki.freepascal.org/SQLdb_Tutorial1
http://wiki.freepascal.org/SQLdb_Tutorial2
Regards
-
Hi,
Thanks for all the replies.
I was a little quick on the trigger as I'm building Dynamic Forms and I was getting a little exasperated by the SIGSEGV exceptions. :-[
The problem was that the IBConnection was improperly set.
My bad. :(