Trouble in updating source in ADO
-
Hi everone, I am having trouble in updating the source database. I am using a dialog based application with a datagrid. I managed to add a number (01065017) to the first coloumn succesfully but could not update the source after the addition of this number. Any Idea why. The following is the code: m_pConn.CreateInstance(__uuidof(Connection)); m_pConn->Open("Provider=Microsoft.Jet.OLEDB.4.0;" "Data Source=ADOTestDB.MDB", _bstr_t (""), _bstr_t (""), adModeUnknown ); m_pComm.CreateInstance(__uuidof(Command)); m_pComm->ActiveConnection = m_pConn; m_pComm->CommandText = "Select * From Student"; m_pReco.CreateInstance(__uuidof(Recordset)); m_pReco->CursorLocation = adUseClient; m_pReco->Open ( (IDispatch *) m_pComm, vtMissing, adOpenStatic, adLockBatchOptimistic, adCmdUnknown); m_DataCtrl.SetCaption("Students"); m_DataCtrl.SetRefDataSource(NULL); m_DataCtrl.SetRefDataSource((LPUNKNOWN) m_pReco); m_DataCtrl.Refresh(); m_pReco->AddNew(); FieldsPtr pFields = m_pReco->Fields; FieldPtr pStudentNo = pFields->GetItem("StudentNo"); ASSERT(NULL != pStudentNo); CString ali = (char*)(_bstr_t) pStudentNo->Value; ali.Format("01065017"); _variant_t vColumn, vValue; vColumn.SetString("StudentNo"); vValue.SetString(ali); m_pReco->Update(vColumn, vValue); m_pReco->Update(); Thanx in advance