UPDATE更改图片字段

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
读: TBlobField * pField=(TBlobField *)pQuery->FieldByName("Image");
TBlobStream * pmem=new TBlobStream(pField,bmRead);
pmem->Seek(0,soFromBeginning);
Graphics::TBitmap * pBitmap=new Graphics::TBitmap();
pBitmap->LoadFromStream(pmem);
Image1->Picture->Assign(pBitmap);
delete pBitmap;
delete pmem;
写:
TBlobField * pField=(TBlobField *)pQuery->FieldByName("Image");
TBlobStream * pmem=new TBlobStream(pField,bmWrite);
pmem->Seek(0,soFromBeginning);
Graphics::TBitmap * pBitmap=new Graphics::TBitmap();
pBitmap->Assign(Image1->Picture->Graphic);
pBitmap->SaveToStream(pmem);
delete pBitmap;
delete pmem;
注意:一定要用此方法进行读写,因为实际上它是以二进制流的方式存入数据库!
 
后退
顶部