Unit1.cpp
Upload User: lhxd_sz
Upload Date: 2014-10-02
Package Size: 38814k
Code Size: 1k
Development Platform:

C++ Builder

  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "Unit1.h"
  5. //---------------------------------------------------------------------------
  6. #pragma package(smart_init)
  7. #pragma resource "*.dfm"
  8. TForm1 *Form1;
  9. //---------------------------------------------------------------------------
  10. __fastcall TForm1::TForm1(TComponent* Owner)
  11.         : TForm(Owner)
  12. {
  13. }
  14. //---------------------------------------------------------------------------
  15. void __fastcall TForm1::Button1Click(TObject *Sender)
  16. {
  17.   Table1->Append();
  18.   Table1->FieldByName("科目代码")->AsString=Edit1->Text.Trim();
  19.   Table1->FieldByName("科目名称")->AsString=Edit2->Text.Trim();
  20.   Table1->Post();
  21. }
  22. //---------------------------------------------------------------------------
  23. void __fastcall TForm1::Button2Click(TObject *Sender)
  24. {
  25.   AnsiString filename;
  26.   filename="test.dbf";
  27.   Query1->Active=False;
  28.   Query1->SQL->Clear();
  29.   Query1->SQL->Add("INSERT INTO ""+filename+"" (科目代码,科目名称)");
  30.   Query1->SQL->Add("VALUES('"+Edit1->Text.Trim()+"','"+Edit2->Text.Trim()+"')");
  31.   Query1->ExecSQL();
  32. }
  33. //---------------------------------------------------------------------------