Re: Saving a array of bytes using ADO

From: yc (yc_at_yc.yc)
Date: 02/18/05


Date: 18 Feb 2005 07:41:04 -0800


Don't worry, I figured it out.
And show you how it is done.

Let's say table have a qry and Memo field called MEM_FLD

Write
-----
var
  Stream: TStream;
  bf : TBlobByteData;
  rc, i : Integer;
begin
  rc := 100;
  SetLength(bf, rc);
  for i := Low(bf) to High(bf) do
  begin
    bf[i] := i;
  end;

  qry.Edit;
  try
    Stream := qry.CreateBlobStream(qry.FieldByName('MEM_FLD') as TBlobField, bmWrite);
    try
      i := Stream.Write(bf[0], rc);
    finally
      Stream.Free;
    end;
  except
    qry.Cancel;
    raise;
  end;
  qry.Post;

Read
-----
var
  bf : TBlobByteData;
  rc : Integer;
begin
  rc := qry.GetBlobFieldData(qry.FieldByName('MEM_FLD').FieldNo, bf); //Returns # of bytes read
end;

"yc" <yc@yc.yc> wrote:
>
>I have a access (mdb) file with the following table and field features.
>TEST_TABLE
> a Text(128)
>
>In my Delphi appl. I would like to be able to save a byte array of 128. ( var a : array[0..127] of byte;)
>In TADOQuery component there is no way of saving an array of bytes. If I manage this for mdb I think I can use the same technique for other DB using ADO components.
>
>Is there any way of doing this ?
>If yes, how ?
>A code snippet is appreciated.
>Thanks in advance
>yc
>



Relevant Pages

  • Re: Replicated records losing data - partially
    ... Sometimes SOME of a memo field stays and the ... Someone added a laptop replia which they sync with the office mdb ... I looked at the generation fields and ... > - Maria (Retired Access consultant, ...
    (microsoft.public.access.replication)
  • Replicated records losing data - partially
    ... We have a split db with a data mdb in the ... Sometimes SOME of a memo field stays and the ... Someone added a laptop replia which they sync with the office mdb ... I looked at the generation fields and ...
    (microsoft.public.access.replication)
  • Re: TRichEdit contents in an Access DB
    ... Rich edit is text you can use a memo field. ... var bs: tBlobStream; ... bs:= tBlobStream.Create (aField, bmWrite); ...
    (borland.public.delphi.database.ado)
  • Re: Retrieving and viewing big, big txtfiles
    ... I did a quick test with a form with 1 button and 1 memo field. ... It's a quick and dirty file read using 32k blocks. ... Repeat ...
    (alt.comp.lang.borland-delphi)