Page 1 of 1

Blob data edit / add problem

Posted: 19.01.2006, 17:07
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!

Posted: 19.01.2006, 18:03
by ssamayoa
Which error?

Which database?

Which component?

Regards.

Posted: 19.01.2006, 18:12
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

Posted: 19.01.2006, 19:16
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).

Posted: 20.01.2006, 10:09
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