请大家帮忙看一下,为什么取出来的纪录集是空的
其中
_Recordset m_pRs;
IADORecordBinding m_piAdoRecordBinding;
det是类AdoRet(继承自CADORecordBinding)的对象
BOOL CAdo_Test_SqlServerDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE; // TODO: add reinitialization code here
// (SDI documents will reuse this document)
m_strCnt = _T("Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=example;Data Source=(local);");
m_strCTt = _T("select * from Department");
m_pRs = NULL;
m_piAdoRecordBinding = NULL;
::CoInitialize(NULL);
try
{
m_pRs.CreateInstance(_uuidof(Recordset));
m_pRs->Open((LPCTSTR)m_strCTt,(LPCTSTR)m_strCnt,adOpenDynamic,adLockOptimistic,adCmdUnknown);
if(FAILED(m_pRs->QueryInterface(_uuidof(IADORecordBinding),(LPVOID*)&m_piAdoRecordBinding)))
_com_issue_error(E_NOINTERFACE); m_piAdoRecordBinding->BindToRecordset(&det);
}
catch(_com_error &e)
{
GError(e.Error(),e.Description());
}
return TRUE;
}
当点击按钮后弹出对话框,在里面的控件里显示第一笔数据,里面用到
m_pRs->MoveFirst();方法,可是为什么得出来的纪录集是空的?请问哪位高手可以指点一下:这是点击按钮后的方法体
DepDlg dlg(this); //对话框派生类
dlg.DoModal();
m_pRs->MoveFirst();
dlg.m_depname = GetAdoRet()->m_Cdepname;
 //GetAdoRet方法返回指向det的指针
//m_Cdepname是与纪录集里的字段做数据绑定的,类型为CString
dlg.m_depmgr = GetAdoRet() ->m_Cdepmgr;
dlg.UpdateData(false);