Click to See Complete Forum and Search --> : Retrieving Blob Data using ADO


muthu555
July 12th, 2002, 07:05 AM
hi,
I have a Table which has a blob DataType for a particular field.I am using ADO to retrieve the Data but i get a exception thrown while callign the open function of the ADO with the select query.Can some one help me out??

{
strAuditQuery = "select AUDIT_ID,Message_sender,Message_Receiver,Message_Data,Product_ID,TRAN_DATE_TIME from AuditTrail where Product_ID = '";
strAuditQuery += m_strSelProductID;
strAuditQuery += "'";
}
if(bSuccTrans)
{
strAuditQuery += " AND Message_Status = 'S'";
}
else if(bFailTrans)
{
strAuditQuery += " AND Message_Status = 'F'";
}

pAuditRecordSet.CreateInstance(__uuidof(Recordset));

HRESULT hr = pAuditRecordSet->Open(_variant_t(strAuditQuery),_variant_t((IDispatch *) pConnection,true),
adOpenKeyset , adLockOptimistic,1);
if(hr==S_OK)
{
long lRecCount = pAuditRecordSet->GetRecordCount();
if(lRecCount>0)
{
int iIndex = 0;
pAuditRecordSet->MoveFirst();
while (!pAuditRecordSet->EndOfFile)
{
_bstr_t strMessSend = pAuditRecordSet->Fields->GetItem("Message_sender")->Value;
_bstr_t strMessRecv = pAuditRecordSet->Fields->GetItem("Message_Receiver")->Value;
_bstr_t strAuditID = pAuditRecordSet->Fields->GetItem("AUDIT_ID")->Value;
_bstr_t strDataTime = pAuditRecordSet->Fields->GetItem("TRAN_DATE_TIME")->Value;
//_bstr_t strMessData = pAuditRecordSet->Fields->GetItem("Message_Data")->Value;
_bstr_t strMessData = pAuditRecordSet->Fields->GetItem("Message_Data")->GetChunk(300);

pAuditRecordSet->MoveNext();
}
}
}

The Message_Data is the BLOB here.
thanx
Muthu