Click here to Skip to main content
15,893,663 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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;




why this area emerge some errors???
Posted
Comments
walterhevedeich 28-Jul-11 5:54am    
What error was it?
wisrael 28-Jul-11 7:49am    
"catch" part would throw an exception:idispatch error#3105.

KarstenK 1-Aug-11 8:26am    
in MOST CASES are error codes and the resovling messages right: so you did something wrong!!!

1 solution

Had you created connection to the database? And also see whether the connection is opened are not? if yes you had given means.Check whether you had declared an class to declare all the the variables that you are using.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900