这个类或许有用.#if !defined( __CPDATABASE_H_ )
#define __CPDATABASE_H_#pragma warning (disable : 4127) // conditional expression is constantclass CCPDatabase : public CDatabase
{
public:
/**/ CCPDatabase()
{
};
//
// Code Is Copied From CDatabase Source Code...
//
virtual BOOL OpenEx( LPCTSTR lpszConnectString, DWORD dwOptions = 0 )
{
dwOptions |= noOdbcDialog; // Force NoDialog Flag For Connection Pooling ASSERT_VALID(this);
ASSERT(lpszConnectString == NULL || AfxIsValidString(lpszConnectString));
ASSERT(!(dwOptions & noOdbcDialog && dwOptions & forceOdbcDialog)); // Exclusive access not supported.
ASSERT(!(dwOptions & openExclusive)); m_bUpdatable = !(dwOptions & openReadOnly); TRY
{
m_strConnect = lpszConnectString; // Allocate the HDBC and make connection
AllocConnect(dwOptions);
if(!Connect(dwOptions))
return FALSE; // Verify support for required functionality and cache info
VerifyConnect();
GetConnectInfo();
}
CATCH_ALL(e)
{
Free();
THROW_LAST();
}
END_CATCH_ALL return TRUE;
}
};
#pragma warning (disable : 4127) // conditional expression is constant
#endif // __CPDATABASE_H_