题目:有两张表,一张是staff(员工号,姓名,工资,所属部门),另一张是department(部门号,部门名称,负责人),要求:(1)通过一个菜单触发一个对话框输入员工姓名,再弹出一个对话框输出该员工所在部门负责人的姓名。(2)在View类中添加一个CRecordset的指针m_pSet来实现(1)的操作。
下面是我的代码,错在哪里呢?void CPersonnelView::OnQuery()
{
// TODO: Add your command handler code here
CString m_mgrName;
CPutStfNameDlg m_putStfName; //输入员工姓名的对话框
if(m_putStfName.DoModal()==IDOK)
{
CString strSQL;
strSQL.Format("select 负责人 from department where 部门名称 = 'select 所属部门 from staff where 姓名 = %s' ",m_putStfName.m_stfName); m_pSet->m_pDatabase->ExecuteSQL(strSQL); m_mgrName = m_pSet->m_column5 ; //在CRecordset中利用RFX机制把m_column5设置为何负责人对应
strOut = "这个部门的负责人是"+ m_mgrName ;
AfxMessageBox(strOut);
}
}
下面是我的代码,错在哪里呢?void CPersonnelView::OnQuery()
{
// TODO: Add your command handler code here
CString m_mgrName;
CPutStfNameDlg m_putStfName; //输入员工姓名的对话框
if(m_putStfName.DoModal()==IDOK)
{
CString strSQL;
strSQL.Format("select 负责人 from department where 部门名称 = 'select 所属部门 from staff where 姓名 = %s' ",m_putStfName.m_stfName); m_pSet->m_pDatabase->ExecuteSQL(strSQL); m_mgrName = m_pSet->m_column5 ; //在CRecordset中利用RFX机制把m_column5设置为何负责人对应
strOut = "这个部门的负责人是"+ m_mgrName ;
AfxMessageBox(strOut);
}
}
{
CString strSQL;
strSQL.Format("select 负责人 from department where 部门名称 = 'select 所属部门 from staff where 姓名 = %s' ",m_putStfName.m_stfName);m_pSet->m_pDatabase->ExecuteSQL(strSQL);while (!m_pSet->EndOfFile)
{
m_mgrName = m_pSet->m_column5 ;//在CRecordset中利用RFX机制把m_column5设置为何负责人对应
strOut = "这个部门的负责人是"+ m_mgrName ;
AfxMessageBox(strOut);
m_pSet->MoveNext();
}
}
catch(_com_error e)
{//......
}
catch(...)
{//.....
}