Hi Guys,
I am trying to Save an image (BMP) to MDB database via ODBC.
The good thing is that I can do it for images with file size less then 512 bytes.
When image size is greather than 512 bytes. I have ODBC Bind error (error screen is attached).
Any idea to fix the error?
my code is below:
procedure TForm1.ToDBClick(Sender: TObject);
var
BinStream: TMemoryStream;
begin
BinStream := TMemoryStream.Create;
SQLQuery1.ReadOnly := false;
SQLQuery1.SQL.Text := 'SELECT Pictures FROM Demo WHERE ID=1';
SQLQuery1.Active := True;
SQLQuery1.Open;
aImage.Picture.Bitmap.LoadFromFile('c:\temp\aaa.bmp');
aImage.Refresh;
aImage.Picture.Bitmap.SaveToStream(BinStream);
BinStream.Position:=0;
SQLQuery1.Edit;
TBlobField(SQLQuery1.FieldByName('Pictures')).Clear;
TBlobField(SQLQuery1.FieldByName('Pictures')).LoadFromStream(BinStream);
//Caption:= IntToStr(BinStream.Size);
SQLQuery1.Post;
SQLQuery1.ApplyUpdates;
SQLQuery1.Close;
SQLQuery1.Active := False;
BinStream.Free;
end;