C++ builder資料庫連接大全

來源:互聯網
上載者:User
最近在用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();
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.