Blob data edit / add problem

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
mvniekerk
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 11.12.2005, 19:13

Blob data edit / add problem

Post by mvniekerk »

Please look at the code. I'm trying to insert a record with blob data (actually a TMemoField). I get an error after the "Post' Command
T.Insert;
try
T.Edit;
MS := T.CreateBlobStream(T.FieldByName('Description'), bmWrite);
Description.SaveToStream(MS);
T.FieldValues['ID'] := ID;
T.FieldValues['Number'] := Number;
T.FieldValues['Name'] := Name;
T.FieldValues['Done'] := Done;
T.FieldValues['DateStarted'] := DateStarted;
T.FieldValues['DateEnded'] := DateEnded;
T.FieldValues['PhotoGroup'] := Photos.GiveID;
T.Post;
except
on Exception do;
end;

Any help would be welcome!
ssamayoa
Junior Boarder
Junior Boarder
Posts: 29
Joined: 14.01.2006, 19:06

Post by ssamayoa »

Which error?

Which database?

Which component?

Regards.
tygrys
Junior Boarder
Junior Boarder
Posts: 33
Joined: 09.12.2005, 18:31
Location: Poland

Post by tygrys »

If you are trying to insert new record use T.Insert.
If you are trying to edit existing recrord use T.Edit.
Not both.

Tygrys
mvniekerk
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 11.12.2005, 19:13

Post by mvniekerk »

On reviewing I see my explanation was a bit vague. :oops:
T is a TZQuery, initiated with T.SQL.Add("Select * from `actionlist`"); T.Active := True;
Description as a variable is a TStrings variable.
The error after the "post" command was 'Cannot insert table, field 'Description' cannot by NULL'
It seems that the TStrings did not copy to the TStream, or the TStream did not update the Description field (which is a TMemoField).
pol
Senior Boarder
Senior Boarder
Posts: 91
Joined: 13.10.2005, 08:19

Post by pol »

As far as I can see: you hava a database field called "Description" and a Memo field with the same name, and you try to fill the database field with the contents of the memo field, using stream MS. But I don't see where you actually fill the database field. No T.FieldValues['Description']. So it is null.
And Tygrys is right too.

Regards,
Rüdiger
Post Reply