ADO programming is very simple, it's similar to VB. If you have multiple
....
....
Bs.As.
Hi,
I have the following code:
// sField = "some column name"
m_pRecordset->Open((LPCSTR)a_sQuery,
m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
while(!m_pRecordset->adoEOF)
{
TheValue = m_pRecordset-
GetCollect((char*)_bstr_t(sField));
if(TheValue.vt!=VT_NULL){
m_pRecordset-
Close();
return((char*)_bstr_t(TheValue));
}
}
It works fine when the select query has one column to select.
But what should I do if the query is of " select * " type ?
I tried the following and the GetCollect Failed:
// sField = "*"
m_pRecordset->Open((LPCSTR)a_sQuery,
m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
while(!m_pRecordset->adoEOF)
{
TheValue = m_pRecordset-
GetCollect((char*)_bstr_t(sField));
if(TheValue.vt!=VT_NULL){
if(resBuf[0] = 0)
strcpy(resBuf, (char*)_bstr_t(TheValue));
else
strcat(resBuf, (char*)_bstr_t(TheValue));
strcat(resBuf, "|");
}
m_pRecordset->MoveNext();
}
m_pRecordset->Close();
return((char*)_bstr_t(TheValue));
Thanks!