zoukankan      html  css  js  c++  java
  • VC++ update数据库的方法

    void Preprocess::SplitDocument(int begin,int end,string tablename)
    {
     char * selectbySpecificId=new char [1000];
     memset(selectbySpecificId,0,1000);
     sprintf_s(selectbySpecificId,1000,"select ArticleId,CAbstract1 ,CAbstract from %s where ArticleId between %d and %d",tablename.c_str(),begin,end);
     if(!ICTCLAS_Init())
     {
      printf("ICTCLAS INIT FAILED!\n");
      string strerr("there is a error");

     }
     ICTCLAS_SetPOSmap(ICT_POS_MAP_SECOND);
     CoInitialize(NULL);
     _ConnectionPtr pConn(__uuidof(Connection));
     _RecordsetPtr pRst(__uuidof(Recordset));
     pConn->ConnectionString="Provider=SQLOLEDB.1;Password=ssssss;Persist Security Info=True; User ID=sa;Initial Catalog=FinallyCorpus";
     pConn->Open("","","",adConnectUnspecified);
     pRst.CreateInstance("ADODB.Recordset");
     pRst->Open(selectbySpecificId,
      _variant_t((IDispatch*)pConn,true),
      adOpenStatic,
      adLockOptimistic,
      adCmdText);

     //pRst=pConn->Execute(,NULL,adCmdText);

     while (!pRst->rsEOF)
     {
      
      string rawtext=(_bstr_t)pRst->GetCollect("CAbstract1");
      //rawtext=ProcessforMSSQL(rawtext);
      string tempid=(_bstr_t)pRst->GetCollect("ArticleId");
      const char* sInput=rawtext.c_str();
      string sResult=ICTsplit(sInput);
      _variant_t vColumn,vValue;
      vColumn.SetString("CAbstract");
      vValue.SetString(sResult.c_str());
      pRst->Update(vColumn,vValue);
      cout<<"finishprocessing"<<tempid<<endl;
      pRst->MoveNext();

     }
     pRst->Close();
     pConn->Close();
     pRst.Release();
     pConn.Release();
     CoUninitialize();
     delete []selectbySpecificId;
     
     ICTCLAS_Exit();


    }

  • 相关阅读:
    Android仿人人客户端(v5.7.1)——个人主页(三)
    hdu2554-N对数的排列问题
    POJ1363:Rails
    golang printf
    HDU1200:To and Fro
    [C# 基础知识系列]专题六:泛型基础篇——为什么引入泛型
    poj 2480 (欧拉函数应用)
    Re:从0开始的微服务架构--(二)快速快速体验微服务架构?--转
    爬虫推荐的工具
    python2 与 python3 语法区别--转
  • 原文地址:https://www.cnblogs.com/finallyliuyu/p/1904865.html
Copyright © 2011-2022 走看看