unit7.cpp

来自「CBUILDER+SQL的实现」· C++ 代码 · 共 43 行

CPP
43
字号
//---------------------------------------------------------------------------

#include <vcl.h>
#pragma hdrstop

#include "Unit7.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
Tbaodao *baodao;
//---------------------------------------------------------------------------
__fastcall Tbaodao::Tbaodao(TComponent* Owner)
        : TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall Tbaodao::Button1Click(TObject *Sender)
{
try
{
Query1->Close();
 Query1->SQL->Clear();
AnsiString strSQL="select sno,sname,ssex,scome,homeAddress,zhuanye,telephone,postalcode ";
  strSQL+="from Student where sname like '%"+LabeledEdit1->Text+"%';";

   Query1->SQL->Add(strSQL);
 Query1->Prepare();
 Query1->Open();
 if(Query1->RecordCount!=0)
 MessageBox(Handle,"查询成功!","信息提示",MB_OK);
 else
  MessageBox(Handle,"查无此人!","信息提示",MB_OK);
 }
  catch(Exception &e)
  {MessageBox(Handle,"查询失败!","信息提示",MB_OK);}
}
//---------------------------------------------------------------------------
void __fastcall Tbaodao::Button2Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?