Erratic save to DB when field is empty

General TRichView support forum. Please post your questions here
Post Reply
jamiemi
Posts: 21
Joined: Sun Oct 30, 2005 3:33 pm

Erratic save to DB when field is empty

Post by jamiemi »

I have a real head scratcher here. Some of the RichViews that I have on a screen cause an error when being saved, others do not. The problem occurswhen saving to database (using ADO). Here is the code I use to save off to the DB field:

function SaveRVFToField(rv: TCustomRichView; tbl: TadoTable;
const FieldName: String): Boolean;
var Stream: TStream;
begin
Stream := tbl.CreateBlobStream(tbl.FieldByName(FieldName), bmWrite);
try
Result := rv.SaveRVFToStream(Stream, False);
finally
Stream.Free;
end;
end;

In the RichViews that do not cause the problem, the stream that is created always has a size of over 600 char - even when the field is NULL. In the RichViews that do cause the error, the stream that is created has a size of 0. I have looked at both sets of RichViews (those that work and those that do not) and see no differences in properties. Likewise, both types have RVStyle objects and those appear to be the same also.

In a nutshell, why does the stream sometimes have lots of characters and other times none? Might there be an initialization that goes to some and not others? When a RichView field is created, are the styles automatically set, or does the field need to be used first?

Thanks
jamie
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Nothing is saved in stream, if RichView.ItemCount=0.
In TRichViewEdit (if it was displayed), ItemCount=1. In this case, something is saved, et least rvf header (and may be styles, background, etc.)
Post Reply