Board index » delphi » Getting memo data from Field?

Getting memo data from Field?

How can I get the memo data from a tsql.fields[n]?
GetData and AsString are not working.  A small snippett
would be great.

Thanks

 

Re:Getting memo data from Field?


In article <clintE4Ix26....@netcom.com>, cl...@netcom.com says...

Quote

>How can I get the memo data from a tsql.fields[n]?
>GetData and AsString are not working.  A small snippett
>would be great.

>Thanks

Not sure if this is what you're trying to do but this will extract a string
from a memo field.  Make sure the char array (P in my example) is large
enough to hold the entire memo.  You could use dynamic memory allocation.

var  
  BS : tBlobStream;             {from the memo field}
  TheString:String;
  P  : array [0..50] of char;   {array size is number of characters needed}
  TheField:String;
begin
  TheField := 'FieldName';
  BS := tBlobStream.Create((TheField as TMemoField), bmRead);
  FillChar(P,SizeOf(P),#0); {terminate the null string}
  BS.Read(P, 50); {read 50 chars from memo into blobStream}
  BS.Free;
  TheString := StrPas(P);
end;

HTH,
Ray

--
-------------------------------------------------------
Pacifier Online Data Service Dialup SLIP/PPP User
To register: (360) 693-0325 or telnet pods.pacifier.com
-------------------------------------------------------

Re:Getting memo data from Field?


Quote
C Carr wrote:

> How can I get the memo data from a tsql.fields[n]?
> GetData and AsString are not working.  A small snippett
> would be great.

> Thanks

I have used this with D 2 to put a memo field into a TStringList.

MyStringList.Assign(MyMemoField);

Mike

Other Threads