Hello ZEOS-Team!
I call the method TZConnection.ExecuteDirect(SQLString,CountRowsAffected) and use a SELECT in the SQLString.
In version "7.2.14-release" I get a TRUE and a CountRowsAffected number back.
In version "8.0.0-release" I get a FALSE and as CountRowsAffected -1 back.
Here is my example code:
program project2;
uses
Classes, SysUtils, ZConnection;
var ZConnection1 : TZConnection;
CountOfRows : integer;
begin
ZConnection1:= TZConnection.Create(nil);
try
With ZConnection1 do
begin
HostName:= '192.168.110.34';
Port:= 3306;
Database:= 'Test';
User:= 'admin';
Password:= 'pasword';
case Version[1] of
'7': Protocol:='MariaDB-10';
'8': Protocol:='mariadb';
end;
{$IFDEF WINDOWS} LibraryLocation:='C:\Windows\System32\libmariadb.dll'; {$ENDIF}
{$IFDEF LINUX} LibraryLocation:= '/usr/lib/x86_64-linux-gnu/libmariadb.so.3'; {$ENDIF}
connect;
Writeln('FPCTARGET'+'= '+{$INCLUDE %FPCTARGET%});
Writeln('FPCTARGETCPU'+'= '+{$INCLUDE %FPCTARGETCPU%});
Writeln('FPCTARGETOS'+'= '+{$INCLUDE %FPCTARGETOS%});
Writeln('FPCVERSION'+'= '+{$INCLUDE %FPCVERSION%});
Writeln('Zeos-Version=',Version);
if connected then
begin
Writeln(LineEnding,'Create table');
Writeln(ExecuteDirect(
'CREATE TABLE IF NOT EXISTS `TestTable` ('+
' `ID` INT AUTO_INCREMENT , '+
' `Name` VARCHAR(100), '+
' `Age` INT, '+
' PRIMARY KEY (`ID`));',
CountOfRows));
Writeln('count of rows=',CountOfRows);
Writeln(LineEnding,'Insert 2 rows');
Writeln(ExecuteDirect(
'INSERT INTO `TestTable`'+
' (`Name`, `Age`) '+
' VALUES '+
' ("Oscar Miller",55),'+
' ("Kevin Smith",15);',
CountOfRows));
Writeln('count of rows=',CountOfRows);
Writeln(LineEnding,'Check Count of rows');
Writeln(ExecuteDirect('SELECT * FROM `TestTable`;',CountOfRows)); // <-------- Problem in Version 8 !!!!
Writeln('count of rows=',CountOfRows);
Writeln(LineEnding,'Update all Rows');
Writeln(ExecuteDirect('UPDATE `TestTable` SET `Age`=`Age`+1;',CountOfRows));
Writeln('count of rows=',CountOfRows);
end;
end;
finally
ZConnection1.Free;
end;
Write(LineEnding,'-->'); Readln;
end.
Do I need to do anything differently to keep my code working?
Best regards
Bernd