4,011
社区成员
发帖
与我相关
我的任务
分享
CDatabase m_db;
if(m_db.IsOpen())
{
AfxMessageBox(_T("数据库已经连接"));
return;
}
CString str;
str.Format(_T("DSN=abcd;UID=amp;PWD=amp"));
if (!m_db.OpenEx(str,CDatabase::noOdbcDialog))
{
AfxMessageBox(_T("数据库连接失败"));//连接不上也不打印 ,我想打印这条
}
AfxMessageBox(_T("数据库连接成功"));
m_db.Close();
CATCH_ALL(e)
{
lResult = AfxProcessWndProcException(e, &pThreadState->m_lastSentMsg);
TRACE(traceAppMsg, 0, "Warning: Uncaught exception in WindowProc (returning %ld).\n",lResult);
DELETE_EXCEPTION(e);
}