如题/

解决方案 »

  1.   

    pRstAuthors->Open("SELECT * FROM Authors",strCnn,
                adOpenDynamic,adLockOptimistic,adCmdText);        
      pRstAuthors->Save("a:\\Pubs.xml",adPersistXML);
    --------------------------------------------------------
     pRstAuthors->Open("a:\\Pubs.xml","Provider=MSPersist;",
                adOpenForwardOnly,adLockOptimistic,adCmdFile);
      

  2.   

    lz可以查阅这里 "C:\Program Files\Common Files\Microsoft Shared\Office10\2052\ADO210.CHM"
    搜索save,看例子就行了
      

  3.   

    pRstAuthors-> Open("a:\\Pubs.xml","Provider=MSPersist;", 
                            adOpenForwardOnly,adLockOptimistic,adCmdFile); 
    这个函数是把XML文件中的数据导入了记录集,没有存到表里面吧?
      

  4.   

    pRstAuthors->PutActiveConnection(_variant_t((IDispatch *) pCnn));
            pRstAuthors->UpdateBatch(adAffectAll);
    这个是我刚才所说的那个文件里的范例,里面有如何把它再存进表里
      

  5.   

    CString sPath="c:\\test.xml";
    _bstr_t strCnn("Provider='sqloledb';Data Source=(local);"
                "Initial Catalog='testdb';Integrated Security='SSPI';");try
    {
     _ConnectionPtr  pCon;
    HRESULT hr=pCon.CreateInstance(__uuidof(Connection)); 
    hr=pCon->Open(strCnn,"","",NULL);_RecordsetPtr pRst;
    pRst.CreateInstance(__uuidof(Recordset));
    pCon->BeginTrans();
    pRst-> Open((LPCTSTR)sPath,"Provider='MSPersist'",adOpenKeyset,adLockBatchOptimistic,adCmdFile); 
    pRst->PutActiveConnection(_variant_t((IDispatch *)pCon));
    hr =pRst->UpdateBatch(adAffectAll);     
    if(SUCCEEDED(hr))     
       pCon->CommitTrans();     
    else     
     {MessageBox(sPath,"错误",MB_ICONERROR);
     }
    pRst->Close();
    pCon->Close();
    }
    catch(_com_error &e)
    {
     MessageBox("错误");
    }
      

  6.   

    单步调试,到pRst-> UpdateBatch(adAffectAll);一直最后都没问题
      

  7.   

    按照ado2.5帮助中的例子实现了一遍,发现如下问题:
     (1)由UpdateBatch()函数只能更新,而不能插入,
     (2)更新数据库的时候打开的文件为adtg文件,而不是导出的xml文件,
       这样想实现把XML文件存回到一个空的表中,肯定是不行的.
       例子的作用只是更新,而不是生成