Hi! Sorry for my english, but i hope you'll understand me :P
I'm trying to create new TSQLQuery component in code, without placing it on form. I wrote that code:
var
sql:tsqlquery;
pole:TFMTBCDField;
....
sql:=tsqlquery.Create(self);
sql.SQLConnection:=ddm.konekszyn;
sql.SQL.Text:='SELECT COUNT(idrap) FROM raporty WHERE idkier="'+lvkierowcy.Selected.Caption+'";';
pole:=TFMTBCDField.Create(self);
pole.Name:='sqlilerap';
pole.FieldName:='COUNT(idrap)';
pole.FieldKind:=fkData;
pole.DisplayLabel:='COUNT(idrap)';
sql.Fields.Add(pole);
sql.Open;
showmessage(sql.FieldByName('COUNT(idrap)').AsString);
sql.Free;
pole.Free;
but i'm getting exception when i try to access data:
First chance exception at $75999617. Exception class EDatabaseError with message 'Field 'COUNT(idrap)' has no dataset'. Process htstrm2.exe (2308)
What should I do ?