procedure TForm1.Button1Click(Sender: TObject);
var
Buffer: PChar;
fd: Integer;
Stream: TMySQLBlobStream;
bmp:TBitmap;
flen:Int64;
begin
bmp:=TBitmap.Create;
try
//向Mysql表写入Bmp图像
bmp.LoadFromFile('c:\program files\common files\borland shared\Images\Splash\256color\factory.bmp');
MySQLQuery1.Open;
MySQLQuery1.Append;
MySQLQuery1.FieldByName('code').AsString:='刘志12';
MySQLQuery1.FieldbyName('image').Assign(bmp);
MySQLQuery1.TableName:='image';
MySQLQuery1.post;
//从Mysql表读出Bmp图像
MySQLQuery1.close;
MySQLQuery1.SQl.Clear;
MySQLQuery1.SQL.Add('select * from image where code="刘志12"');
MySQLQuery1.Open;
MySQLQuery1.Next;
MySQLQuery1.Edit;
Stream := TMySQLBlobStream.Create(MySQLQuery1.FieldByName('Image') as TBlobField, bmReadWrite);
bmp.LoadFromStream(stream);
canvas.Draw(0,0,bmp);
finally
Stream.Free;
bmp.Free;
end;
end;
========================
不如这样UPDATE table_name SET blob_column=LOAD_FILE("/tmp/picture")
WHERE id=1;
关键要用file权限而且文件要在server上面。