15,471
社区成员
发帖
与我相关
我的任务
分享
// 执行查询操作的回调函数
void CCSFrame::DoQuery()
{
.....
// 申请数据库连接
CADODatabase* pDataBase = NULL;
m_pSysFrame->GetDatabase( &pDataBase);
.........
// 启动查询线程
boost::thread thread(boost::bind(&CCSFrame::QueryThread, this, cmd, pDataBase));
m_queryThread.swap(thread);
}
// 查询线程
void CCSFrame::QueryThread(CADOCommand& cmd, CADODatabase* pDataBase)
{
ASSERT( pDataBase);
USES_CONVERSION;
double dbValue;
CString szValue;
COleDateTime dtValue;
CADORecordset rs( pDataBase);
COleDateTime dtStart = COleDateTime::GetCurrentTime();
BOOL bResult = rs.Execute(&cmd, adUseServer);
//获取数据
...
rs.Close();
PostMessage(UM_QUERYCOMPLETE, 0, (LPARAM)pDataBase);
}
//窗口关闭
void CCSFrame::OnDestroy()
{
CFrameParent::OnDestroy();
// TODO: Add your message handler code here
m_queryThread.join();
}