Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Datenbanken (https://www.delphipraxis.net/15-datenbanken/)
-   -   Delphi invalid statement handle (https://www.delphipraxis.net/78385-invalid-statement-handle.html)

smudo 4. Okt 2006 09:34

Datenbank: Interbase • Version: 6.2 • Zugriff über: UIB

invalid statement handle
 
Hallo,

ich kann mit dieser Fehlermeldung nichts anfangen:
Zitat:

invalid statement handle
Unsuccessful execution caused by system error that does not preclude successful execution of subsequent statements
Error Code: 165
Was mache ich:
Delphi-Quellcode:
with dm.Q01 do //TJvUIBQuery
begin
  SQL.Text := 'Insert into ... Values(:Val01, :Val02, ...)';
  if not(Transaction.InTransaction) then
    Transaction.StartTransaction;
  Prepare;
  while not ... do
  begin
    dm.FillParam(dm.Q01, 'Val01', ..., ftString);  //Füllt die Parameter
    dm.FillParam(dm.Q01, 'Val02', ..., ftInteger);
    ExecSQL;
    ...
  end;
  Transaction.Commit; //Rollback wird im Try-Except-Block ausgelöst
end;

procedure Tdm.FillParam(aQ: TJvUIBQuery; const aParamName: String; const aField: TField;
  const aFieldType: TFieldType; const SetNullIfEmpty: Boolean);
var ParamIndex: Word;
begin
  ParamIndex := aQ.Params.GetFieldIndex(aParamName);
  if aField = Nil then
    aQ.Params.IsNull[ParamIndex] := True else
  if aField.IsNull then
    aQ.Params.IsNull[ParamIndex] := True else
  if (SetNullIfEmpty) and
     (aField.AsString = '') then
    aQ.Params.IsNull[ParamIndex] := True else
  case aFieldType of
    ftInteger: aQ.Params.AsInteger[ParamIndex] := aField.asInteger;
    ftString: aQ.Params.AsString[ParamIndex] := aField.asString;
    else raise Exception.CreateFmt('FillParam: Unknown FieldType for %s', [aParamName]);
  end;
end;
Das funktioniert auch mehrfach. Will ich danach schreibend auf die DB zugreifen, kommt es zu obengenanntem Fehler.
Was könnte hier noch offen sein?

Vielen Dank im Voraus

René

smudo 4. Okt 2006 09:58

Re: invalid statement handle
 
Hallo René :zwinker:,

das ist doch ganz einfach. Verwende doch Execute anstelle von ExecSQL, dann gehts.

Nur falls es auch mal jemand anderes trifft.


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:19 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz