Firebird 2.5 TIBConnection TSQLTransaction and Error Operator is not overloaded lazarus / 16-Databases ---------------------------------------------------------------------- rc.1990 · 2016-09-24 05:45 I am using Windows 7 64 bit, Firebird 2.5.6 64 bit server, Lazarus 1.6.0 32 bit, FPC 3.0.0 32 bit. fbclient.dll (Firebird 2.5.6 32 bit) and test.fdb are on the the same folder of project1.exe. Connection to local database file is tested and working correctly. Why does line 32 "SQLTransaction1 := TSQLTransaction.Create(nil);" shows error "project1.lpr(32,19) Error: Operator is not overloaded: - 'TSQLTransaction' "? ---------------------------- Compile Project, Target: project1.exe: Exit code 1, Errors: 6, Warnings: 2 project1.lpr(32,3) Warning: Variable "SQLTransaction1" does not seem to be initialized project1.lpr(32,19) Error: Operator is not overloaded: - "TSQLTransaction" project1.lpr(48,3) Warning: Variable "SQLQuery1" does not seem to be initialized project1.lpr(48,13) Error: Operator is not overloaded: - "TSQLQuery" project1.lpr(63,18) Error: Incompatible types: got "untyped" expected "LongInt" project1.lpr(63,25) Error: Illegal expression project1.lpr(67,16) Error: Incompatible types: got "untyped" expected "LongInt" project1.lpr(67,21) Error: Illegal expression ---------------------------- Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program project1; {$mode objfpc} uses  Classes, SysUtils, IBConnection, sqldb; var  IBConnection1: TIBConnection;  SQLTransaction1: TSQLTransaction;  SQLQuery1: TSQLQuery; begin  IBConnection1 := TIBConnection.Create(nil);  IBConnection1.HostName := 'localhost';  IBConnection1.DatabaseName := 'test.fdb';  IBConnection1.UserName := 'SYSDBA';  IBConnection1.Password := 'masterkey';  // IBConnection1.CharSet := 'UTF8';  IBConnection1.CharSet := 'ISO8859_1';  IBConnection1.Dialect := 3;  IBConnection1.Params.Add('port=3050');  IBConnection1.LoginPrompt := False;  IBConnection1.Connected := True;   if IBConnection1.Connected then    WriteLn('Connected.')  else    WriteLn('Not connected.');   ----------------------------  SQLTransaction1 :=  TSQLTransaction.Create(nil);  // SQLTransaction1.Params.Add('read_committed');;  // SQLTransaction1.Params.Add('rec_version');;  // SQLTransaction1.Params.Add('nowait');;  SQLTransaction1.Database := IBConnection1;  SQLTransaction1.Params.Add('isc_tpb_read_committed');;  SQLTransaction1.Params.Add('isc_tpb_rec_version ');;  SQLTransaction1.Params.Add('isc_tpb_nowait');;  SQLTransaction1.StartTransaction;   if SQLTransaction1.Active then    WriteLn('Transaction started.')  else    WriteLn('Transaction not started.');   ------------  SQLQuery1 := TSQLQuery.Create(nil);  SQLQuery1.Database := IBConnection1;  SQLQuery1.Transaction := SQLTransaction1;  SQLQuery1.SQL.Text := 'Select ID, Name From People;';  SQLQuery1.Open;  while not SQLQuery1.Eof do  begin    WriteLn('ID: ', SQLQuery1.FieldByName('ID').AsInteger,             'Name: ' + SQLQuery1.FieldByName('Name').AsString);    SQLQuery1.Next;  end;  SQLQuery1.Close;  SQLQuery1.Free;  ------------   SQLTransaction1.Commit;  SQLTransaction1.Free;  ----------------------------   IBConnection1.Free;end. ---------------------------------------------------------------------- wp · 2016-09-24 05:54 What if you comment the dividing lines? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ....  if IBConnection1.Connected then    WriteLn('Connected.')  else    WriteLn('Not connected.');   //----------------------------                       <-- add comment slashes here  SQLTransaction1 :=  TSQLTransaction.Create(nil);.... ---------------------------------------------------------------------- rc.1990 · 2016-09-24 06:18 Thanks wp. I have removed them all and now the program is working. Now I have a small problem on character encoding (code page or UTF) in WriteLn on command line (CMD) of Windows 7. The Firebird database is encoded as ISO8859_1 not UTF8 and its information is showed correctly. The database information is correct: "Teste Soluções", but the WriteLn information is wrong: "ID/C├│digo: 1   Name/Razão Social:". It should be "ID/Código: 1  Name/Razão Social:". ------------------ Microsoft Windows [versão 6.1.7601] Copyright (c) 2009 Microsoft Corporation. Todos os direitos reservados. C:\test>project1.exe Connected. Transaction started. ID/C├│digo: 1       Name/Razão Social: Teste Soluções C:\test> ------------------ ---------------------------------------------------------------------- wp · 2016-09-24 09:11 Use the conversion routines in lconvencoding and lazutf8: - ISO_8859_1ToUtf8() for conversion from IS8869-1 to UTF8 - UTF8ToConsole() for conversion from UTF8 to codepage used by console Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  WriteLn('ID: ', SQLQuery1.FieldByName('ID').AsInteger,         'Name: ' + UTF8ToConsole(ISO_8859_1ToUTF8(SQLQuery1.FieldByName('Name').AsStr ing))); ---------------------------------------------------------------------- rc.1990 · 2016-09-24 13:17 Thanks wp. I can't use UTF8ToConsole() and ISO_8859_1ToUTF8(). It seems that I missing something in the USES clause, but I don't know which unit is still missing. ------------- Compile Project, Target: project1.exe: Exit code 1, Errors: 1 project1.lpr(7,3) Fatal: Cannot find LazUtils used by project1. Check if package LazUtils is in the dependencies of the Project Inspector. ------------- Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program project1; {$mode objfpc}{$apptype console} uses  LazUtils, LazUTF8, LConvEncoding, Classes, SysUtils, IBConnection, sqldb; ---------------------------------------------------------------------- wp · 2016-09-24 13:32 Read the error message: "Check if package LazUtils is in the dependencies of the Project Inspector" - this means: open the project inspector. The package "LazUtils" should be mentioned in the tree underneath "Required packages". If it is not right-click on "Required packages", "Add...", and select "LazUtils" from the list. And remove "LazUtils" from the uses list - this is a package (a collection of units), not a unit. ---------------------------------------------------------------------- rc.1990 · 2016-09-24 14:37 Thanks wp. Now, everything is working perfectly. I am releasing the final version here just in case it might help anyone else. I am also attaching the final images of the Project Inspector. file: project1.lpr: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program project1; {$mode objfpc}{$apptype console} uses  LazUtils, LazUTF8, LConvEncoding, Classes, SysUtils, IBConnection, sqldb; var  IBConnection1: TIBConnection;  SQLTransaction1: TSQLTransaction;  SQLQuery1: TSQLQuery;begin  IBConnection1 := TIBConnection.Create(nil);  IBConnection1.HostName := 'localhost';  IBConnection1.DatabaseName := 'test.fdb';  IBConnection1.UserName := 'SYSDBA';  IBConnection1.Password := 'masterkey';  // IBConnection1.CharSet := 'UTF8';  IBConnection1.CharSet := 'ISO8859_1';  IBConnection1.Dialect := 3;  IBConnection1.Params.Add('port=3050');  IBConnection1.LoginPrompt := False;  IBConnection1.Connected := True;   if IBConnection1.Connected then    WriteLn('Connected.')  else    WriteLn('Not connected.');   SQLTransaction1 :=  TSQLTransaction.Create(nil);  // SQLTransaction1.Params.Add('read_committed');;  // SQLTransaction1.Params.Add('rec_version');;  // SQLTransaction1.Params.Add('nowait');;  SQLTransaction1.Database := IBConnection1;  SQLTransaction1.Params.Add('isc_tpb_read_committed');;  SQLTransaction1.Params.Add('isc_tpb_rec_version ');;  SQLTransaction1.Params.Add('isc_tpb_nowait');;  SQLTransaction1.StartTransaction;   if SQLTransaction1.Active then    WriteLn('Transaction started.')  else    WriteLn('Transaction not started.');   SQLQuery1 := TSQLQuery.Create(nil);  SQLQuery1.Database := IBConnection1;  SQLQuery1.Transaction := SQLTransaction1;  SQLQuery1.SQL.Text := 'Select ID, Name From People;';  SQLQuery1.Open;  while not SQLQuery1.Eof do  begin    WriteLn(UTF8ToConsole('ID/Código: '), SQLQuery1.FieldByName('ID').AsInteger, '   ',            UTF8ToConsole('Name/Razão Social: ') + ISO_8859_1ToUTF8(SQLQuery1.FieldByName('Name').AsString));    SQLQuery1.Next;  end;  SQLQuery1.Close;  SQLQuery1.Free;   SQLTransaction1.Commit;  SQLTransaction1.Free;   IBConnection1.Connected := False;  IBConnection1.Free;end.  file: project1.lpi: Code: XML  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i                                                               <UseAppBundle Value="False"/>      <ResourceType Value="res"/>    </General>    <i18n>      <EnableI18N LFM="False"/>    </i18n>    <VersionInfo>      <StringTable ProductVersion=""/>    </VersionInfo>    <BuildModes Count="1">      <Item1 Name="Default" Default="True"/>    </BuildModes>    <PublishOptions>      <Version Value="2"/>    </PublishOptions>    <RunParams>      <local>        <FormatVersion Value="1"/>      </local>    </RunParams>    <RequiredPackages Count="1">      <Item1>        <PackageName Value="LazUtils"/>      </Item1>    </RequiredPackages>    <Units Count="1">      <Unit0>        <Filename Value="project1.lpr"/>        <IsPartOfProject Value="True"/>      </Unit0>    </Units>  </ProjectOptions>  <CompilerOptions>    <Version Value="11"/>    <PathDelim Value="\"/>    <Target>      <Filename Value="project1"/>    </Target>    <SearchPaths>      <IncludeFiles Value="$(ProjOutDir)"/>      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>    </SearchPaths>  </CompilerOptions>  <Debugging>    <Exceptions Count="3">      <Item1>        <Name Value="EAbort"/>      </Item1>      <Item2>      <Name Value="ECodetoolError"/>      </Item2>      <Item3>        <Name Value="EFOpenError"/>      </Item3>    </Exceptions>  </Debugging></CONFIG>