Recordset AddNew fails
-
I derived a Class "CProtocol" from CRecordset which is linked with but one database table. Everything works fine until I call AddNew(), here I receive a assertion Faile Message, referring to dbcore.cpp Code sniplet ( .cpp file): CString csTimeNow; // Hole Hostnamen DWORD dwHostLength = MAX_COMPUTERNAME_LENGTH + 1; GetComputerName( csComputerName.GetBuffer( 0), &dwHostLength); // Hole UserNamen DWORD dwUserLength = UNLEN + 1; GetUserName( csUserName.GetBuffer( 0), &dwUserLength); // Hole aktuelle Zeit COleDateTime coTimeNow(COleDateTime::GetCurrentTime()); csTimeNow.Format( "%04d%02d%02d%02d%02d%02d00", coTimeNow.GetYear(), coTimeNow.GetMonth(), coTimeNow.GetDay(), coTimeNow.GetHour(), coTimeNow.GetMinute(), coTimeNow.GetSecond()); // Instanz zur Datenbank aufbauen CString csConnectionString; csConnectionString = "DSN=ODR_CRM;UID=ODRGMBH;PWD=origin"; m_pDB = new CDatabase(); if( m_pDB->OpenEx(csConnectionString,CDatabase::noOdbcDialog)) { // We´re connected to the database } else { // we have a problem connecting to the database } // Access to Class Protokoll Table m_pProtocol = new CProtokoll( m_pDB); m_pProtocol->Open(); // ready to use m_pProtocol->m_Timestamp = csTimeNow; m_pProtocol->m_Benutzer = csUserName; m_pProtocol->m_Rechner = csComputerName; m_pProtocol->m_Aktion = csMessage; if( m_pProtocol->IsOpen() ) { m_pProtocol->AddNew(); // Ready to add new records } m_pProtocol->Update(); // Update Table m_pProtocol->Requery(); // .h file CDatabase* m_pDB; // Pointer to CDatabase Class CProtokoll* m_pProtocol; // Pointer to CRecordset Class