unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, Grids, DBGrids, DBTables;
type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
DataSource1: TDataSource;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
public
Query1: TQuery;
end;
var
Form1: TForm1;
Field1: TFloatField;
implementation
procedure TForm1.FormCreate(Sender: TObject);
begin
Query1 := TQuery.Create(Self);
Field1 := TFloatField.Create(nil);
Field1.FieldName := 'Cislo';
Field1.DisplayWidth := 5;
Field1.Precision := 2;
Query1.Fields.Add(Field1);
Query1.Active := True;
DataSource1.DataSet := Query1;
try
Query1.Append;
Query1.Fields[0].AsFloat := 10;
Query1.Post;
finally
end;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Query1.Free;
end;
end.
Čo robím zle? Ak povolím riadok Field1.Size, tak dostanem chybu, že je to chybná dĺžka, ak to nepovolím, tak pri Active := True dostanem "No SQL statement available". Keďže je tabuľka vytváraná v pamäti, tak jej fyzické meno neexistuje. Zrejme je chyba niekde v tom. Tiež by ma zaujímalo, čo s tou dĺžkou.