这样的sql
select * from warrant,myuser where warrant.user_id=myuser.id;
两个表都有"data_id"字段
用访问_RecordsetPtr
m_pRecordset->GetCollect("myuser.data_id");
m_pRecordset->GetCollect("warrant.data_id");
都出错.请问应该如何访问?
select * from warrant,myuser where warrant.user_id=myuser.id;
两个表都有"data_id"字段
用访问_RecordsetPtr
m_pRecordset->GetCollect("myuser.data_id");
m_pRecordset->GetCollect("warrant.data_id");
都出错.请问应该如何访问?
_bstr_t filedname[12];
CString caption="";
long kk=m_pUserSet->GetFields ()->GetCount ();
for (long uu=0;uu<kk;uu++)
{
filedname[uu]=m_pUserSet->GetFields ()->GetItem ((_variant_t)uu)->GetName ();
filed[uu]=m_pUserSet->GetCollect (filedname[uu]);
}
filedname[uu]中有两个是"data_id",他们的值是一样的,
事实上连接后的两个"data_id"子段是不同的.
_FieldPtr m_FidHRESULT hr;
try
{
CString str;
hr=m_pSet->Open((_bstr_t)sql,\
&(*m_pCon),adOpenForwardOnly,adLockOptimistic,adCmdText);
if(SUCCEEDED(hr))
{
m_pSet->Close();
return;
}
long i; //i用来记录返回列的数目
m_pSet->Fields->get_Count(&i);
m_pSet->MoveFirst();
for(int j=0;j<i;j++)
{
m_Fid=m_pSet->Fields->GetItem((short)j);
str=(char*)(_bstr_t)m_Fid->GetName();//取得列名
while(!m_pSet->EndOfFile)
{
for(int j=0;j<i;j++)
{
_variant_t Holder;
Holder.Clear();
Holder=m_pSet->GetCollect((short)j);
if(Holder.vt!=VT_NULL)
{
str.Format("%d",Holder.intVal);
}
}
m_pSet->MoveNext();
}
m_pSet->Close();
}
}
catch(_com_error *e)
{
CString Error=e->ErrorMessage();
AfxMessageBox(Error);
}