You are not logged in.
Pages: 1
I need save an image into my database, for this I use this code:
SaveAsRawByteString(imgDocument.Picture,doc,gptJPG,80,1500);
ContattoRecord := TSQLContacts.Create;
try
ContattoRecord.Name = "something";
ContattoRecord.Lastname= "something";
id := Database.Add(ContattoRecord, true);
if id > 0 then
begin
Database.UpdateBlob(TSQLContacts, id, 'Document', doc)
end;
finally
ContattoRecord.Free;
end;
The image is not save into DB. I have check doc variable after SaveAsRawByteString with this code:
MessageDlg(UTF8ToString(doc),mtError, mbOKCancel, 0);
IAnd I get always a black message.
I have use both BMP anf PNG like images for my test.
Any idea?
Offline
I think that you've missed
SaveAsRawByteString(imgDocument.Picture,doc,gptJPG,80,1500);
ContattoRecord := TSQLContacts.Create;
try
ContattoRecord.Name = "something";
ContattoRecord.Lastname= "something";
ContattoRecord.Document := doc; <--------------------------------------
id := Database.Add(ContattoRecord, true);
if id > 0 then
begin
Database.UpdateBlob(TSQLContacts, id, 'Document', doc)
end;
finally
ContattoRecord.Free;
end;
Offline
I don't use ForceBlobTransfert so I don't need set ContattoRecord.Document because Database.Add don't use it.
Offline
I think I have found a possible problem: I don't have add this code to my unit:
initialization
Gdip.RegisterPictures;
I'm remeber taht with this code in the pas my code works however on recent Delphi version (XE3 and XE6) if I add these line I get an error.
On Delphi XE6 I get
"Exception class EFilerError with message 'A class named TJpegImage already exists'" line 1081 of SynGdiPlus.pas
How can I fix it.
Offline
If I comment this 2 lines of SynGdiPlus.pas (on Delphi XE6)
RegisterClass(TJpegImage);
RegisterClass(TPngImage);
all works. I thinks is need to add exceptions depending on the version of the compiler.
Offline
Pages: 1