try { nFlag = 1; sql.Format(_T("select * from slptext where slptext.CountryID = (select CountryID from country where Country=\'%s\')"),m_langname); m_pRecordset->Open(sql,CADORecordset::openUnknown); sql.Format(_T("select * from country where Country=\'%s\'"),m_langname); m_pRecord->Open(sql,CADORecordset::openUnknown); m_pRecord->GetFieldValue(0,countryID); if(!(m_pRecordset->IsBOF()))//若记录集指针未指向数据库中的首元素 { m_pRecordset->MoveFirst();//则将其指向首元素位置 } while (!m_pRecordset-> IsEOF()) { m_pRecordset->GetFieldValue(2,origTxt); if (origTxt == sEng && (origTxt != _T(""))){ nFlag = 0; break; } m_pRecordset->MoveNext(); } if (nFlag==0) {////////////////////// m_pRecordset->SetFieldValue(3, sOL); m_pRecordset->Update(); //AfxMessageBox(_T("插入Translate Text数据库成功!")); } else{ m_pRecordset->AddNew(); m_pRecordset->SetFieldValue(0, countryID); m_pRecordset->SetFieldValue(1, szHash); m_pRecordset->SetFieldValue(2,sEng); m_pRecordset->SetFieldValue(3, sOL); m_pRecordset->Update(); //AfxMessageBox(_T("插入新记录数据库成功!")); } } catch(_com_error *e) { //MessageBox(e->ErrorMessage()); CString errMsg; errMsg.Format(_T("数据库操作失败:%s,%s"),e->ErrorMessage(),e->Description()); AfxMessageBox(errMsg); } m_pRecordset->Update(); m_pRecordset->Close(); m_pRecord->Close(); m_pRecord = NULL; m_pRecordset = NULL;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)