Why does a commit trigger an access violation?

喜你入骨 提交于 2021-01-07 01:25:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!