Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Problem with storing table in BLOB
Sun, Jan 6 2008 11:48 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

My next problem is that something is weird about the way memory tables are getting stored in a blob field.

I've checked edb.RecordCount at this point

  if edb.RecordCount > 0 then EDBTableToEDBMemo(Fld, edb, Interim) else Interim.FieldByName(Fld).Clear;
  Interim.Post;

in the migration code. Most times the recordcode is between 8 & 11 inclusive with one value of 4 and one of 22. However, when I go to the app where this is used (StreamMemoToTable) I generally get a recordcount of 2.

In the original app naturally I see all the images.

I've tried setting the memory stream's position back to 0 in both migrator and app but no go.

Roy Lambert

procedure EDBTableToEDBMemo(Fld: string; SrcTbl: TEDBTable; DestTbl: TEDBTable);
var
ms: TMemoryStream;
begin
ms := TMemoryStream.Create;
try
 SrcTbl.SaveToStream(ms);
 TBLOBField(DestTbl.FieldByName(Fld)).LoadFromStream(ms)
finally
 ms.Free;
end;
end;


function StreamMemoToTable(Fld: string; SrcTbl: TEDBDataset; DestTbl: TEDBTable; OpenExclusive: boolean = False): boolean;
var
ms: TMemoryStream;
begin
try
 DestTbl.Close;
 DestTbl.Exclusive := True;
 ClearTable(DestTbl);
 DestTbl.Close;
 DestTbl.Exclusive := OpenExclusive;
 DestTbl.Open;
 if not SrcTbl.FieldByName(Fld).IsNull then begin
  ms := TMemoryStream.Create;
  TBLOBField(SrcTbl.FieldByName(Fld)).SaveToStream(ms);
  try
   if ms.Size > 0 then begin
    DestTbl.LoadFromStream(ms);
    DestTbl.Refresh;
    DestTbl.First;
   end;
  finally
   ms.Free;
  end;
 end;
 Result := True;
except
 Result := False;
end;
end;
Mon, Jan 7 2008 7:32 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< In the original app naturally I see all the images.

I've tried setting the memory stream's position back to 0 in both migrator
and app but no go. >>

Could you send me a sample of this ?

--
Tim Young
Elevate Software
www.elevatesoft.com

Tue, Jan 8 2008 3:33 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


I've sent my code as per request in the other post. What sort of sample would you like? Table before and after?

Roy Lambert
Tue, Jan 8 2008 10:20 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< I've sent my code as per request in the other post. What sort of sample
would you like? Table before and after? >>

Table before is fine.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image