我想知道怎么从数据库读写二进制数据
SQL Server 里面的二进制文件好像是binary类型的。
我使用的是ADO控件。
我想知道读写这个二进制的语法和基本的用法。
谢谢了
[解决办法]
以下代码是将图像存储和读出二进制数据字段的演示:
// 读
TBlobField *bf = (TBlobField *)ADOQuery1->FieldByName("字段名");
TADOBlobStream *bs = new TADOBlobStream(bf, bmRead);
bs->Seek(0, soFromBeginning);
Graphics::TBitmap *bmp = new Graphics::TBitmap();
bmp->LoadFromStream(bs);
Image1->Picture->Assign(bmp);
delete bmp;
delete bs;
// 写
ADOQuery1->Edit();
TBlobField *bf = (TBlobField *)ADOQuery1->FieldByName("字段名");
TADOBlobStream *bs = new TADOBlobStream(bf, bmWrite);
bs->Seek(0, soFromBeginning);
Graphics::TBitmap *bmp = new Graphics::TBitmap();
bmp->Assign(Image1->Picture->Graphic);
bmp->SaveToStream(bs);
delete bmp;
delete bs;
ADOQuery1->Post();