You are not logged in.
Pages: 1
hi,
i have a TSQLRecordMany descendant class.
i would like to have a method that can create a TObjectList of TSQLRecordMany.
Something like this
ObjectList := TObjectList<TSQLBaseMany>.Create;
ObjectList.OwnsObjects := True;
SQLBaseMany.FillMany(aClient, aSourceID);
while SQLBaseMany.FillOne do
begin
ObjectList.Add(SQLBaseMany);
end;
Result := ObjectList;
FreeAndNil(SQLBaseMany);
But when i call the method for second time i get an AV on SQLBaseMany.FillOne. Can you help me to understand where i mistake?
Thanks,
Emanuele.
Offline
if i have TSQLRecordMany published property is a real instance after TSQLRecord.create, its right?
Offline
Yes, but you call FreeAndNil(SQLBaseMany); therefore you release the SQLBaseMany instance.
So how are you creating the SQLBaseMany instance?
It is not shown in your code!
And you are adding the same object instance to your list.
This is not correct, from the Delphi point of view.
You have to create a new instance each time, then fill the newly created instance.
See for instance, how methods TSQLTable.ToObjectList () or TSQLTable.ToObjectList<T>: TObjectList<T> are implemented.
Online
ok, forget my code. i try to explain all situation.
i have a component that taken a tObjectList is able to show and elaborate it, so i would like to get a tObjectList from a generic TSQLRecordMany property.
now, think about mORMotUIEdit and his TRecordEditForm.SetRecord procedure.
Well, i would like to implement this part of code
sftBlob, sftMany:
; // not implemented yet
reading a tObjectList from TSQLRecordMany property and pass it to my component.
What is the correct and fast way to do?
thanks ab for the help!
Offline
it's clear my situation and what i would like to do?
any idea?
Offline
yes i know, but i would like to implement but i need some help.
for example:
i read in the documentation that TSQLRecordMany property of a TSQLRecord class is an instance but...
why aValue is empty? (aValue = '')
aValue := P.GetValue(aRecord,false);
aFieldType := Fields.List[i].SQLFieldType;
case aFieldType of
sftDateTime: begin
CD := TDateTimePicker.Create(Scroll);
CD.Kind := dtkDate;
CD.DateTime := Iso8601ToDateTime(aValue);
end;
sftTimeLog, sftModTime: begin
CD := TDateTimePicker.Create(Scroll);
CD.Kind := dtkDate;
TimeLog.Value := GetInt64(pointer(aValue));
CD.DateTime := TimeLog.ToDateTime;
end;
sftCreateTime:
; // is low-level read/only field by design
sftBlob, sftMany:
; // not implemented yet <------------------WHY here aValue IS EMPTY??
can you help me to understand?
Offline
yes i know that it is not implemented yet, i would like to implement but i can't understand how read the TSQLRecordMany instance by RTTI!
i try
case aFieldType of
sftDateTime: begin
CD := TDateTimePicker.Create(Scroll);
CD.Kind := dtkDate;
CD.DateTime := Iso8601ToDateTime(aValue);
end;
sftTimeLog, sftModTime: begin
CD := TDateTimePicker.Create(Scroll);
CD.Kind := dtkDate;
TimeLog.Value := GetInt64(pointer(aValue));
CD.DateTime := TimeLog.ToDateTime;
end;
sftCreateTime:
; // is low-level read/only field by design
sftBlob, sftMany:
begin
obj := TSQLRecordMany(Pointer(aValue)); //but aValue = ''!!!!! WHY??
end;
thanks,
Emanuele
Offline
Pages: 1