Problems updating Blob field
Posted: 16.11.2009, 13:20
Hi,
I'm trying to update a Blob field in one of my tables from a small word doc file that is stored in a TStream.
I'm using Delphi 7, Zeos 6.6.5, and MySQL 5.0.x
My update code is as follows :
My logging statements produce the following output :
Which seems to sugest to me that the blob data is never being sent to the MySQL server, and the Blob field is remaining null.
Does anyone know how I can get this working ?
Cheers.
Phill.
I'm trying to update a Blob field in one of my tables from a small word doc file that is stored in a TStream.
I'm using Delphi 7, Zeos 6.6.5, and MySQL 5.0.x
My update code is as follows :
Code: Select all
PROCEDURE TChemDataModule.SaveDatasheet(InChemicalIDNo : Cardinal;
Datasheet : TStream;
FileName : STRING);
VAR Blob : TStream;
BEGIN;
WITH ZDatasheetQuery DO
BEGIN;
IF (NOT LocateDatasheet(InChemicalIDNo)) THEN
BEGIN;
Append;
FieldByName(DBFChemDataChemID).AsInteger:=InChemicalIDNo;
END;
FieldByName(DBFChemDataFilename).AsString:=FileName;
Blob:=CreateBlobStream(FieldByName(DBFChemDataDatasheet),bmWrite);
TRY
Datasheet.Seek(soFromBeginning,0);
Debug.Log('Blob.Size=%d, Datasheet.Size=%d',[Blob.Size,Datasheet.Size]);
Blob.CopyFrom(Datasheet,0);//Datasheet.Size);
Debug.Log('Blob.Size=%d',[Blob.Size]);
post;
ApplyUpdates;
FINALLY
Blob.Free;
END;
END;
END;
Code: Select all
[127.0.0.1] [/:0] Blob.Size=0, Datasheet.Size=48640
[127.0.0.1] [/:0] Blob.Size=48640
[127.0.0.1] [/:0] SQLLog:2009-11-16 12:09:35 cat: Execute, proto: mysql-5, msg: INSERT INTO TestChemicalDB.datasheets (chemical_id,datasheet,filename) VALUES (23,NULL,'industrial methylated spirit.doc')
Does anyone know how I can get this working ?
Cheers.
Phill.