CString CTestDG2View::GetTreeCatalog(int ParentID)
{
CString RetInfo;
RetInfo = "<Root>"; BOOL bFind = FALSE;
try
{
int nIndex=0; //记录序号
CString strSQL = "";
strSQL.Format(" select * from PostsType where TypeID = %d ",ParentID);
m_pRecordSet->Open(_variant_t(strSQL),
m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
if(!m_pRecordSet->adoEOF)
{
while (!m_pRecordSet->adoEOF)//记录尾
{
_variant_t var;
CString strName;
CString strTypeID;
CString strCatalogURL;
CString strParentID;
CString strDisplayOrder; RetInfo +="<RowItem>";
RetInfo +="<Name>";
var = m_pRecordSet->GetCollect("Name");
if (var.vt != VT_NULL)
{
strName = (LPCSTR)_bstr_t(var);
}
RetInfo +=strName+"</Name>"; RetInfo +="<CatalogURL>";
var = m_pRecordSet->GetCollect("CatalogURL");
if (var.vt != VT_NULL)
{
strCatalogURL = (LPCSTR)_bstr_t(var);
}
RetInfo +=strCatalogURL+"</CatalogURL>"; RetInfo +="<TypeID>";
var = m_pRecordSet->GetCollect("TypeID");
if (var.vt != VT_NULL)
{
strTypeID = (LPCSTR)_bstr_t(var);
}
RetInfo +=strTypeID+"</TypeID>"; RetInfo +="<ParentID>";
var = m_pRecordSet->GetCollect("ParentID");
if (var.vt != VT_NULL)
{
strParentID = (LPCSTR)_bstr_t(var);
}
RetInfo +=strParentID+"</ParentID>"; RetInfo +="<DisplayOrder>";
var = m_pRecordSet->GetCollect("DisplayOrder");
if (var.vt != VT_NULL)
{
strDisplayOrder = (LPCSTR)_bstr_t(var) ;
}
RetInfo +=strDisplayOrder+"</DisplayOrder>"; RetInfo +="</RowItem>";
int TypeID = (int )atoi(strTypeID);
RetInfo += GetSubCatalog( TypeID ) ;
m_pRecordSet->MoveNext(); nIndex++; //记录序号加1
}
}
else
{
bFind = FALSE;
}
m_pRecordSet->Close();//关闭
}
catch(_com_error *)
{
//AfxMessageBox(e->ErrorMessage());
//要用日志替换
}
catch(...)
{
AfxMessageBox("访问数据库时发生异常。");
//要用日志替换
//return "";
}
RetInfo+="</Root>"; return RetInfo;
}
解决方案 »
- [求助]利用DirectInput 在VC下实现后台鼠标模拟
- 有懂硬盘ATA指令的人吗?校验扇区的操作码是什么?
- window meidia services wms发布点授权问题
- 请问哪里有IE的SDK下载请问哪里有IE的SDK下载
- 求教GetWindowThreadProcessId问题
- 什么叫做相似度计算?为什么经过相似度计算、图像二值化、水平直方图、垂直直方图就可以得到了人脸的区域?
- Undo/Redo功能该如何实现?找了很多办法,没有一个比较好的方案,希望能得到大家的指点。
- 问VC++中文版帮助何处有?不知是否有人告诉我!
- 为什么用RawSocket原始套接字接受UDP数据时,只收到了数据,没有收到IP头和UDP头,见代码.能解决就散分
- 我有4副图片,怎么无缝隙拼接到一起 显示
- 多线程wininet对于COOKIE的问题
- 编译器的问题
CString CTestDG2View::GetSubCatalog(int ParentID)
{
CString RetInfo;
RetInfo= "";
// try
// {
int nIndex=0; //记录序号
CString strSQL = "";
strSQL.Format( "select * from PostsType where ParentID = %d ", ParentID);
m_pSubRecordSet->Open(_variant_t(strSQL),
m_pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
if(!m_pSubRecordSet->adoEOF)
{
cmom.LogsWrite("Enter");
while (!m_pSubRecordSet->adoEOF)//记录尾
{
cmom.LogsWrite("Enter2");
_variant_t var;
CString strName;
CString strTypeID;
CString strCatalogURL;
CString strParentID;
CString strDisplayOrder; RetInfo +="<RowItem>";
RetInfo +="<Name>";
var = m_pSubRecordSet->GetCollect("Name");
if (var.vt != VT_NULL)
{
strName = (LPCSTR)_bstr_t(var);
}
RetInfo +=strName+"</Name>";
RetInfo +="<TypeID>";
var = m_pSubRecordSet->GetCollect("TypeID");
if (var.vt != VT_NULL)
{
strTypeID = (LPCSTR)_bstr_t(var);
}
RetInfo +=strTypeID+"</TypeID>";
RetInfo +="</RowItem>";
int TypeID = (int )atoi(strTypeID);
RetInfo += GetSubCatalog( TypeID ) ;
m_pRecordSet->MoveNext();
nIndex++;
cmom.LogsWrite("logout");
}
cmom.LogsWrite("Enter3");
}
m_pSubRecordSet->Close();//关闭
// }
// catch(_com_error *e)
// {
// //AfxMessageBox(e->ErrorMessage()+"sub");
// AfxMessageBox("subException");
// //要用日志替换
// }
// catch(...)
// {
// AfxMessageBox("访问数据库时发生异常sub。");
// //要用日志替换
// } return RetInfo;
}