Question

I am using TQuery to insert record into table. Below is the code for that.

with qryABC do
    begin
      Close;
      SQL.Clear;
      SQL.Text := 'INSERT INTO tableXYZ (ID) values (:ID)';
      ParamByName('ID').Value := AnyID;
      ExecSQL;
      Close;
    end;

When I fire same query from oracle, query gets fired, but giving exception when I try to fire the query from delphi xe2. While debugging, I found out that I get error on "ExecSQL" statement in above code. Exception is: EDBEngineError - Operation Not Applicable

I googled it but with no fruit. Please help.

Était-ce utile?

La solution

What is AnyID ? With questions like this better to show datatype declaration and value assigned.

As a general suggestion - don't use .Value, try ParamByName('ID').AsInteger or ParamByName('ID').AsString or what u actually need that certain parameter to be.

Not only that would be faster but it also produces more determinate code with compile-time type checking, rather than significantly slower and much less predictable runtime dynamic Variant datatype conversions.

This applies to Fields as well as too Parameters.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top