Board index » delphi » Retrieving a memo field from access.

Retrieving a memo field from access.


2004-04-20 10:34:54 PM
delphi92
Hi.
I have problems with the following sections of code. I was expecting that the RecentContactsLVChange event would end with the memo control being populated with contents that reflected the contents of the retrieved TMemoField. It does not.
I have tested the query in a testbed application and ensured that it returns the expected data.
There are design reasons for me not using a data-aware memo control at this stage.
Please help - I am about to start banging my head on the desk.
Database is JET4/access 2000.
TIA
Neil
procedure TContactDbCentralDM.GetTextFromMemoStore(TextId:integer; MS:TMemoryStream);
begin
MS.Clear;
TextDetailsByNumberADOQ.Close;
TextDetailsByNumberADOQ.Parameters.ParamByName('memo_id_param').Value:=TextId;
TextDetailsByNumberADOQ.Open;
if TextDetailsByNumberADOQ.RecordCount = 1 then
begin
TMemoField(TextDetailsByNumberADOQ.FieldByName('Memo')).SaveToStream(MS);
end;
end;
procedure TPeopleForm.RecentContactsLVChange(Sender: TObject;
Item: TListItem; Change: TItemChange);
var
MS:TMemoryStream;
TextItemPlaceHolder,i:integer;
str:string;
begin
if RecentContactsLV.Selected <>nil then
begin
try
MS:=TMemoryStream.Create;
TextItemPlaceHolder:=RecentContactsLV.ItemIndex;
str:=ContactDbCentralDM.IncidentDetailsTextEntrySL.Strings[i];
TextItemPlaceHolder:=StrToInt(str);
ContactDbCentralDM.GetTextFromMemoStore(TextItemPlaceHolder,MS);
ContactDetailsMemo.Lines.LoadFromStream(MS);
finally
FreeAndNil(MS);
end;
end;
end;
 
 

Re:Retrieving a memo field from access.

Brian
Thanks but will this work for large amounts (say 1000+ chars) I also need to preserve line breaks (I was hoping not to have to parse for them)?
Regards
Brian Bushay TeamB <XXXX@XXXXX.COM>writes:
Quote
Your are trying too hard

if TextDetailsByNumberADOQ.RecordCount = 1 then
begin

ContactDetailsMemo.Lines.text :=
TextDetailsByNumberADOQ.FieldByName('Memo').asString