首页  编辑  

UPDATE更改图片字段

Tags: /超级猛料/Database.数据库相关/SQL Server/   Date Created:
读:
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;
注意:一定要用此方法进行读写,因为实际上它是以二进制流的方式存入数据库!