BCB 读取oracle BLOB并保存到文件
用一下方法可以实现将文件保存到Oracle Blob,但不知道怎样可以实现将Blob内容导出到文件
TMemoryStream* pMS = new TMemoryStream;
pMS->LoadFromFile("D:\\a.txt");//logfile.txt"); // Ñ¡ÔñÒ»¸öÎļþ,¶ÁÈëÁ÷
pMS->Position=0;
pMS->Seek(0,soFromBeginning); // ÉèÁ÷Ö¸Õë 0
ADOQuery1->Active = false;
ADOQuery1->SQL->Clear();
ADOQuery1->SQL->Add("update aaa set programfile =:PHOTO where ID =:RECORDID");
ADOQuery1->Parameters->Items[0]->LoadFromStream(pMS,ftBlob);
ADOQuery1->Parameters->Items[1]->Value = 1;//RecordID;
ADOQuery1->ExecSQL();
delete pMS;
ADOQuery1->SQL->Text = "select * from aaa";
ADOQuery1->Open();
报不支持数据类型错误
[解决办法]
用TBlobField转换再读写。
[解决办法]
TMemoryStream *memStream = new TMemoryStream; TBlobField *tmpField = (TBlobField *)CustomerData->ADOQuery1->FieldByName( "photo"); tmpField->SaveToStream(memStream); tmpField->SaveToStream(memStream); memStream->SaveToFile( "temp.bmp "); delete memStream;
[解决办法]
关键是这个!
Provider=OraOLEDB.Oracle
或
Provider=OraOLEDB.Oracle.1