2. Visual Studio 메뉴에 Insert - New ATL Object 에서
Data Access - Consumer - Command로 하고 DB접근 옵션을 설정한다. (command옵션은 change, insert, delete모두해주고..)
3. 생성된 템플릿에
ULONG m_BLOBDATA_LENGTH;
ULONG m_BLOBDATA_STATUS;
를 추가하고...
BLOB_ENTRY(2, IID_ISequentialStream, STGM_READ, m_data1)
같은 코드를
BLOB_ENTRY_LENGTH_STATUS(2, IID_ISequentialStream, STGM_READ, m_data1, m_BLOBDATA_LENGTH, m_BLOBDATA_STATUS)
로 수정한다.
4. BLOB타입을 사용하기 위해서는 ISequentialStream을 사용해야되는데 사용상의 편의를 위해서 MSDN에서 긁어온(?) 상속받은 소스를 추가한다
class CISSHelper : public ISequentialStream
{
public:
ULONG m_cRef; // Reference count (not used).
ULONG m_iReadPos; // Current index position for reading from the buffer.
ULONG m_iWritePos; // Current index position for writing to the buffer.
};
// ISSHelper.cpp: implementation of the CISSHelper class.
//
//////////////////////////////////////////////////////////////////////
// Calculate bytes left and bytes to read.
ULONG cBytesLeft = m_ulLength - m_iReadPos;
ULONG cBytesRead = cb > cBytesLeft ? cBytesLeft : cb;
// If no more bytes to retrive return S_FALSE.
if ( 0 == cBytesLeft ) return S_FALSE;
// Copy to users buffer the number of bytes requested or remaining
memcpy( pv, (void*)((BYTE*)m_pBuffer + m_iReadPos), cBytesRead );
m_iReadPos += cBytesRead;
// Return bytes read to caller.
if ( pcbRead ) *pcbRead = cBytesRead;
if ( cb != cBytesRead ) return S_FALSE;
char p[32];
memset(p, 0x00, sizeof(p));
int nSize = 32;
CISSHelper ISSHelper2;
memset(p, 0x00, sizeof(p));
ULONG ulBytesRead;
if ( DBSTATUS_S_OK != rs.m_BLOBDATA_STATUS )
{
AfxMessageBox("뷁343432");
}
do
{
hr = rs.m_data1->Read( p, nSize, &ulBytesRead );
if ( FAILED(hr) )
{
AfxMessageBox("뷁2");
}
// Stuff data into helper class which is used as a dynamic buffer here.
hr = ISSHelper2.Write( p, nSize, NULL );
if ( FAILED(hr) )
{
AfxMessageBox("뷁3");
};
}
while ( ulBytesRead < 0 );
RECENT COMMENT