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


    }

  • 相关阅读:
    MySQL8.0新增配置参数
    CF1153F Serval and Bonus Problem
    win10 uwp xaml 绑定接口
    win10 uwp xaml 绑定接口
    Windows Community Toolkit 3.0 新功能 在WinForms 和 WPF 使用 UWP 控件
    Windows Community Toolkit 3.0 新功能 在WinForms 和 WPF 使用 UWP 控件
    win10 uwp 渲染原理 DirectComposition 渲染
    dotnet 从入门到放弃的 500 篇文章合集
    C# ValueTuple 原理
    WPF 使用 Direct2D1 画图入门
  • 原文地址:https://www.cnblogs.com/finallyliuyu/p/1904865.html
Copyright © 2020-2023  润新知