기본카테고리

[Oracle] BLOB 관련

DBRef 2013. 3. 26. 21:16




728x90
<BLOB 받아서 파일로 저장>
CComVariant BlobFile; if(FAILED(ipRow->get_Value(FileIndex, &BlobFile))) { 	MessageBox(0, "COULD NOT RETRIEVE BLOB FILE", "TESTING", MB_OK); 	return false; }  MessageBox(0, "Before writing to stream", "TESTING", MB_OK); CComPtr<IStream> ipStream; HRESULT hr = ::CreateStreamOnHGlobal(NULL, TRUE, &ipStream); BlobFile.WriteToStream(ipStream);  IBlobStreamPtr ipBlobStream(ipStream); MessageBox(0, "Before saving to file", "TESTING", MB_OK); if(ipBlobStream == NULL) { 	MessageBox(0, "ipBlobStream is null", "TESTING", MB_OK); 	return false; }
if(BlobFile.vt == VT_UNKNOWN) {   IBlobStreamPtr ipBlobStream;   BlobFile.punkVal->QueryInterface(&ipBlobStream);   if(ipBlobStream)     ipBlobStream->SaveToFile((CComBSTR)"C:\\ChrisKrootsAtlas.mxd"); }
 
 
<BLOB 필드에 데이터 삽입>
 

CFile testFile
testFile. Open(fileString,CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone,NULL);
if(testFile)
{
DWORD dLength = testFile.GetLength();
Buffer =new BYTE[dLength];
UINT nBytesRead = testFile.Read(Buffer,dLength);
strFileName=testFile.GetFileName();
CString strString;
testFile.Close();
}