Jump to content
Sign in to follow this  
limelect

Data Base does not save data

Recommended Posts

I have an RTE file which at the end has 3 bytes 02 00 00

Using FDTable with SQLite

 

  FDConnection1.ExecSQL('CREATE TABLE IF NOT EXISTS Projects (MyDateTime DateTime,ProjectName TEXT,ProjectrealName TEXT,Category TEXT NULL,Description TEXT NULL,FilesIndex INTEGER)');


Description TEXT NULL =TEXT

First, try

ProjectsFDTable.FieldByName(',Description').AsString := MY RTE TEXT

ProjectsFDTable.Post;

ProjectsFDTable.Refresh;

Last 3 bytes get deleted !!!

 

Can I use it as a string?????????

 

Second try as a BLOB

Description BLOB NULL =BLOB

var

  BlobField:TBlobField;
Stream : TStream ;

 

   Stream := TStream.Create;    <<<<<<<<< I do not free the stream


     BlobField := ProjectsFDTable.FieldByName('Description') as TBlobField;
       Stream := ProjectsFDTable.CreateBlobStream(BlobField, bmWrite);
      xxxx.SaveToStream(Stream);

ProjectsFDTable.Post;

ProjectsFDTable.Refresh;

 

After Refresh I can see the stream has changed to the data size as needed.

BUT NO DATA IN Description field !!!!! 

 

closing the application and looking at the database no description data.

I did not manipulate the field let Delphi do the work

Edited by limelect

Share this post


Link to post

Thank you everybody for your kind help.

Can someone open a site, not for novices?

Even professionals need sometime help

Share this post


Link to post

Even professionals can't really do much without actual source code.
Can you reproduce the problem in a self contained compilable example?

Share this post


Link to post

@Lars Fosdal Thanks. All the source is in the question.

I thought I was very clear with the problem.

In any case, it took me a while but I fixed it.

The answer is

 

     xxxx.SaveToStream(S);
      TBlobField(ProjectsFDTable.FieldByName('Description')).LoadFromStream(S);
Thanks in any case

Share this post


Link to post

@Lars Fosdal You did not read carefully the problem !!!

since RTE file which at the end has 3 bytes 02 00 00

 

The database truncate !!! those bytes when using string

You have to use a blob. 

You can reload the data a string which

from which I use it as a stream

   s := ProjectsFDTable.FieldByName('Description').AsString;

    St := TStringStream.Create(S);
It all comes to this component >>>> AdvRichEditor

Share this post


Link to post

Do not know why. It was easier on my head.

No reason to be perfect.

 

Looking at my source ProjectsFDTable.FieldByName('Description').AsString;

has NO BLOB

D10.2.3

Edited by limelect

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×