A problem updating FoxPro table.
-
Hello everyone. I'm new to C++ and I can't get this to work. Please let me know if I'm doing something wrong besides my problem :) I can not update two fields in FoxPro database it gives me an error "Can't update. Database or object is read-only" This is how it goes: CDaoDatabase* pDatabase = new CDaoDatabase; pDatabase->Open("C:\\Work\\UpdateDBF\\INPUT", //path only! TRUE, //exclusive? FALSE, //read only? "FoxPro 3.0;"); //connect string CDaoRecordset rsCUST(pDatabase); rsCUST.Open(dbOpenDynaset, "SELECT Custnum, noemail, norent FROM [CUST.dbf]"); rsCUST.MoveFirst(); //move to the beginning so we start from the begin rsCUST.FindFirst( "Custnum = " + strCustNum );// strCustNum is a number i pull from a text file if (rsCUST.IsEOF != 0){//if found the record oleTemp.ChangeType( VT_BOOL ); oleTemp.boolVal = true; try { // this is where it fails // the error i get is "Can't update. Database or object is read-only" rsCUST.SetFieldValue("noemail", oleTemp); rsCUST.SetFieldValue("norent", oleTemp); } catch(CDaoException* e){ TCHAR szCause[255]; CString strFormatted = _T("The data file could not be updated because of this error: \n"); e->GetErrorMessage(szCause, 255); strFormatted += szCause; AfxMessageBox(strFormatted, MB_OK | MB_ICONEXCLAMATION); } catch (...) { TRACE ( "*** Unhandled Exception ***" ); } } //if (rsCUST.IsEOF != 0){ If any one know please let me know Thank you in advance. ilya iluha