问题1 (_bstr_t)pRst->GetCollect("client_project");返回乱码
sql1.Format("select * from ClientProject where client_id='%s'",(char*)(LPCTSTR)m_client_id.GetAt(i));//select * from ClientProject where client_id='001'
pRst=m_pConnection->Execute((_bstr_t)sql1,NULL,adCmdText);while(!pRst->adoEOF)
{
(_bstr_t)pRst->RecordCount;
tvInsert.hParent = main_sun1[i];
tvInsert.item.pszText =(char*)(LPCTSTR)(_bstr_t)pRst->GetCollect("client_project");
//(char*)(LPCTSTR)(_bstr_t)pRst->GetCollect("client_project");添加到树中总是显示乱码
//但用MessageBox((char*)(LPCTSTR)(_bstr_t)pRst->GetCollect("client_project"));就OK
tvInsert.item.iImage=2;
tvInsert.item.iSelectedImage=5;
HTREEITEM main_sun1_1=GetTreeCtrl().InsertItem(&tvInsert);
pRst->MoveNext();
}
问题2
如何通过记录集获得表内数据数
sql1.Format("select * from ClientProject where client_id='%s'",(char*)(LPCTSTR)m_client_id.GetAt(i));//select * from ClientProject where client_id='001'
pRst=m_pConnection->Execute((_bstr_t)sql1,NULL,adCmdText);
如何通过pRst获得表内数据数量,试过int k=pRst->RecordCount;没用
sql1.Format("select * from ClientProject where client_id='%s'",(char*)(LPCTSTR)m_client_id.GetAt(i));//select * from ClientProject where client_id='001'
pRst=m_pConnection->Execute((_bstr_t)sql1,NULL,adCmdText);while(!pRst->adoEOF)
{
(_bstr_t)pRst->RecordCount;
tvInsert.hParent = main_sun1[i];
tvInsert.item.pszText =(char*)(LPCTSTR)(_bstr_t)pRst->GetCollect("client_project");
//(char*)(LPCTSTR)(_bstr_t)pRst->GetCollect("client_project");添加到树中总是显示乱码
//但用MessageBox((char*)(LPCTSTR)(_bstr_t)pRst->GetCollect("client_project"));就OK
tvInsert.item.iImage=2;
tvInsert.item.iSelectedImage=5;
HTREEITEM main_sun1_1=GetTreeCtrl().InsertItem(&tvInsert);
pRst->MoveNext();
}
问题2
如何通过记录集获得表内数据数
sql1.Format("select * from ClientProject where client_id='%s'",(char*)(LPCTSTR)m_client_id.GetAt(i));//select * from ClientProject where client_id='001'
pRst=m_pConnection->Execute((_bstr_t)sql1,NULL,adCmdText);
如何通过pRst获得表内数据数量,试过int k=pRst->RecordCount;没用
{
AfxMessageBox("Create Instance failed!");
return;
} CString strSRC = GetConnSrc(strPath, strFn);
CString strSQL; strSQL = "select * from ClientProject order by client_id asc"; try
{
if(FAILED(pPtr->Open(_bstr_t(strSQL), _bstr_t(strSRC), adOpenStatic, adLockOptimistic, adCmdText)))
{
AfxMessageBox("Open table failed!");
pPtr.Release();
return;
}
}
catch(...)
{
AfxMessageBox("打开数据库出错!");
pPtr->Close();
}
HTREEITEM hRoot = m_wndTree.GetRootItem();
while(!pPtr->GetadoEOF())
{
_variant_t varId = pPtr->GetCollect("client_id");
CString strId = (char *)_bstr_t(varId); _variant_t varname = pPtr->GetCollect("name");
CString strname = (char *)_bstr_t(varname); HTREEITEM hItem = m_wndTree.InsertItem(_T(strname), 9, 9, hRoot);
pPtr->MoveNext();
}
pPtr->Close();
pPtr.Release();
tvInsert.item.pszText =(char*)(LPCTSTR)(_bstr_t)var;2\http://blog.csdn.net/zaodt/archive/2008/04/15/2295164.aspx
单步调试到HTREEITEM main_sun1_1=GetTreeCtrl().InsertItem(&tvInsert);就出现栈溢出
但如果
tvInsert.item.pszText ="11111";
HTREEITEM main_sun1_1=GetTreeCtrl().InsertItem(&tvInsert);就正常