Thanks for the help Nigel. Your code worked perfectly for a normal
TTable, but I am using ODBCExpress, and for some reason it wouldn't let
me typecast the field as a TMemofield or TBlobfield. But I got on the
right track and found the CreateBlobStream() function which does the job
I need.
�
procedure ReadStringFromField(SourceDataSet: TOEDataset; SourceField:
String; Slist: TStrings);
var
�� Stream: TStream;
begin
���
Stream:=SourceDataSet.CreateBlobStream(SourceDataSet.FieldByName(SourceF
ield),bmRead);
��� Slist.LoadFromStream(Stream);
��� Stream.Free;
end;
�
procedure WriteStringToField(SourceDataSet: TOEDataset; SourceField:
String; Slist: TStrings);
var
�� Stream: TStream;
begin
��� SourceDataSet.Edit;
���
Stream:=SourceDataSet.CreateBlobStream(SourceDataSet.FieldByName(SourceF
ield),bmWrite);
��� Stream.Write(Slist.GetText^,Strlen(Slist.GetText));
��� SourceDataSet.Post;
��� Stream.Free;
end;


-----Original Message-----
From: Nigel Tavendale [ mailto:[EMAIL PROTECTED]]
Sent: Monday, 1 February 1999 10:06
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Memo strings


Putting In BlobStreams is fairly easy, just remeber to create and
destroy them.
�
e.g.
�
procedure TfmMain.Blob;
var
� slDesc : TStringList;
� bDesc� : TBlobStream;
begin
� {get contentsout of memo field in Table 1}
�slDesc:=TStringList.Create; //create string list
�bDesc:=TBlobStream.Create(TMemoField(Table1.FieldByName('FieldName')),b
mRead); /*Create Blobstream for reading
�slDesc.LoadFromStream(bdesc); /* fill string list with blobstream
contents
�bDesc.Free; /*destroy blobstream
�
{load contents into memo field of Table 2}
��� try
���� bDesc:=TBlobStream.Create(TMemoField
(Table2.FieldByName('FieldName')),bmWrite); /*create blobstream for
writing
���� bDesc.Write(slDesc.GetText^,StrLen(slDesc.GetText));/*Load
blobstream with string list contents
�� finally
���� bDesc.Free; /* destroy blobstreram
���� slDesc.Free; /* destroy stringlist 
� end; /* try - finaly block
end;
�
�
Nigel Tavendale


-----Original Message-----
From: Scott Cree < [EMAIL PROTECTED]>
To: Multiple recipients of list delphi < [EMAIL PROTECTED]>
Date: Friday, 29 January 1999 15:10
Subject: [DUG]: Memo strings


Hi All,

What is the best way to load a memo field (from an Access db) into a
stringlist object, and later save the stringlist back into the memo
field.
I have looked at the LoadFromStream method for TStrings, but I haven't
worked with streams yet, and I'm still trying to get to grips with them.

Cheers

__________________________
Scott Cree
Knowlysis Limited

Phone: +649-358-0017
Fax: +649-358-3534
E-Mail: [EMAIL PROTECTED]


------------------------------------------------------------------------
---
��� New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
����������������� Website: http://www.delphi.org.nz



---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to