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();


    }

  • 相关阅读:
    发红包案列——继承和集合
    抽象类
    方法重写
    继承——访问成员变量,访问成员方法,访问构造方法
    js异步计时器
    栈(stack)和堆(heap)
    高并发和多线程概念
    集群、负载均衡、分布式、微服务
    Redis性能监控
    Redis配置
  • 原文地址:https://www.cnblogs.com/finallyliuyu/p/1904865.html
Copyright © 2011-2022 走看看