zoukankan      html  css  js  c++  java
  • C++ builder数据库连接大全

    最近在用BCB做个小项目,因为自己没学过C++,BCB也是第一次接触所以想在网上找点资料,但发现BCB的东西很少,而且关于数据库操作方面的东西都说的很笼统,不能给找资料的人提供帮助,所以我就把自己知道的一点关于BCB数据库方面的一点东西分享给大家,希望对初学者有所帮助。

    1.数据库的查询
       Query1->Close();
       Query1->SQL->Clear();
       Query1->SQL->Add("select soft_name,soft_vision,soft_org from soft_info where ");
       Query1->SQL->Add("host_ip='192.168.1.111'");
       Query1->ExecSQL();  

    //上面是将结果集保存在Query1中
    int q=Query1->RecordCount;
    if(Query1->FindFirst())   //查找结果集中的第一条记录
    {
      a=Query1->operator []("soft_name");
      b=Query1->operator []("soft_vision");
      c=Query1->operator []("soft_org");
      Memo1->Lines->Add(" Èí¼þÃû£º"+a);
      Memo1->Lines->Add(" Èí¼þ°æ±¾£º"+b);
      Memo1->Lines->Add(" Èí¼þÉÌ£º"+c);
      Memo1->Lines->Add("");
      int m=1;
      while(m<q){
      if(Query1->FindNext())   //查找结果集中的下一条记录
      {
        a=Query1->operator []("soft_name");
        b=Query1->operator []("soft_vision");
        c=Query1->operator []("soft_org");
        Memo1->Lines->Add(" Èí¼þÃû£º"+a);
        Memo1->Lines->Add(" Èí¼þ°æ±¾£º"+b);
        Memo1->Lines->Add(" Èí¼þÉÌ£º"+c);
        Memo1->Lines->Add("");
      }
      m++;
      }
    }

    //上面是将每条记录存到控件中

    2.数据库的添加
    Query1->Close();
    Query1->SQL->Clear();
    Query1->SQL->Add("insert into soft_info (soft_name,soft_vision,soft_org,host_ip) values ('");
    Query1->SQL->Add(name->operator [](j)+"','");
    Query1->SQL->Add(version->operator [](j)+"','");
    Query1->SQL->Add(pub->operator [](j)+"','");
    Query1->SQL->Add("109.128.10."+AnsiString(j+1)+"')");
    Query1->ExecSQL();

    3.数据库的删除
    Query1->Close();
    Query1->SQL->Clear();
    Query1->SQL->Add("delete from soft_info");
    Query1->ExecSQL();
    Query1->DataSource->DataSet->Refresh();
  • 相关阅读:
    confluence --常用插件整合
    fuse--s3挂载到centos7.5服务器
    gvm--go版本管理工具
    等保1.0与等保2.0的区别
    postfix -- 发件调试
    postfix邮件服务器
    confluence -- 命令行备份还原
    浏览器使用小tip
    windows如何正确下载补丁包
    xwiki使用中的问题
  • 原文地址:https://www.cnblogs.com/top5/p/1891388.html
Copyright © 2011-2022 走看看