Lazarus

Programming => Databases => Topic started by: cov on April 10, 2013, 10:23:38 pm

Title: SISEGV on opening SQLQuery1.
Post by: cov on April 10, 2013, 10:23:38 pm
I'm getting SIGSEGV errors on my firebird Database.

Code: [Select]
        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?
Title: Re: SISEGV on opening SQLQuery1.
Post by: goodname on April 11, 2013, 03:12:44 am
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;.
Title: Re: SISEGV on opening SQLQuery1.
Post by: WallE on April 11, 2013, 08:15:14 am

try commenting out these lines !!
Code: [Select]
        SQLQuery1.ExecSQL;
        IBConnection1.Connected:=True;
        SQLTransaction1.Active:=True;
 

Title: Re: SISEGV on opening SQLQuery1.
Post by: BigChimp on April 11, 2013, 08:53:48 am
I wouldn't disable the transaction stuff. Spelling things out can be good ;)
You'd get something like this:
Code: [Select]
        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;
Title: Re: SISEGV on opening SQLQuery1.
Post by: exdatis on April 11, 2013, 08:56:47 am
See:
http://wiki.freepascal.org/SQLdb_Tutorial1
http://wiki.freepascal.org/SQLdb_Tutorial2
Regards
Title: Re: SISEGV on opening SQLQuery1.
Post by: cov on April 11, 2013, 09:17:51 am
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.  :(
TinyPortal © 2005-2018