问题
The following code using the Community version of Delphi and Interbase 2020 running on a Windows 10 machine results in the following error when the Commit is executed. What am I doing wrong?
Project FamilyTree.exe raised exception class $C0000005 with message ‘access violation at 0x00481a6f: read of address 0x8b57569f’.
procedure writepreamble;
var
sqltext : string;
basicaction : tbasicaction;
begin
sqltext := 'insert into preambleds(preambleseq,text) values(';
sqltext := sqltext+inttostr(preambleseq)+','+quotedstr(cardimage)+');';
datamodule1.IBSQL1.SQL.text := sqltext;
datamodule1.geddb.DefaultTransaction := datamodule1.IBTransaction1;
datamodule1.IBsql1.Transaction := datamodule1.IBTransaction1;
datamodule1.IBsql1.Transaction.StartTransaction;
datamodule1.ibsql1.ExecuteAction(basicaction) ;
datamodule1.IBsql1.Transaction.Commit;
sqlcount := sqlcount+1;
end;
回答1:
why you are using `ExecuteAction` ?
use `ExecQuery` to execute insert :
IBSQL1.ExecQuery();
best regards
Moskw@
来源:https://stackoverflow.com/questions/65037457/why-does-a-commit-trigger-an-access-violation