I'm trying to insert a pdf file into a blob field within mysql. When I run the following code I get no compiler errors, it just doesn't write any data to the database.
BTW, I'm running Delphi 2006, MySQL5.0, and using the ODBC connector 3.51. I can read, insert, update all other data just fine. This BLOB thing is just giving me a fit.
If anyone can point me in the right direction I sure would appreciate it.
Thanks
Code:
procedure TForm1.Button1Click(Sender: TObject);
var
ReadFile: TFileStream;
BlobField: TBlobField;
BS: TStream;
begin
ADODataSet1.CommandText := 'SELECT * FROM MachineParts WHERE ID = 3';
ADODataSet1.Active := true;
ADODataSet1.Edit;
BlobField := ADODataSet1.FieldByName('DRAWING') AS TBlobField;
BS := ADODataSet1.CreateBlobStream(BlobField,bmWrite);
BS.Seek(0, soFromBeginning);
ReadFile := TFileStream.Create('C:\Line-Card.pdf', fmOpenRead or fmShareDenyWrite);
BS.CopyFrom(ReadFile, ReadFile.Size);
ReadFile.Free;
BS.Free;
ADODataSet1.Active := false;
end;
BTW, I'm running Delphi 2006, MySQL5.0, and using the ODBC connector 3.51. I can read, insert, update all other data just fine. This BLOB thing is just giving me a fit.
If anyone can point me in the right direction I sure would appreciate it.
Thanks