void CSimpleDBView::OnAddRecord() { // Get address of the document that goes with this view CSimpleDBDoc* pDoc; pDoc=GetDocument(); // Add a blank row to the Authors recordset pDoc->m_simpleDBSet.AddNew(); // Blank out the recordset member variables for new row // // IMPORTANT NOTE: you must put some kind of value into at // least one of the fields (for example, a // zero in a numeric field or maybe the // constant "" into a CString field). // If all of the fields have a NULL value, // the ODBC driver will not add the new row // to the database (i.e., it will not add // a row full of NULLs to the table). // pDoc->m_simpleDBSet.SetFieldNull(&(m_pSet->m_au_id), FALSE); pDoc->m_simpleDBSet.SetFieldNull(&(m_pSet->m_author), FALSE); pDoc->m_simpleDBSet.m_year_born=0; // post new row to the database pDoc->m_simpleDBSet.Update(); // refresh the dynaset/requery and move to last record pDoc->m_simpleDBSet.Requery(); pDoc->m_simpleDBSet.MoveLast(); // reinitialize/repaint the dialog box UpdateData(FALSE); }