unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, DB, ADODB, StdCtrls;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Button1: TButton;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Edit1: TEdit;
Edit2: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
var sqlstr:string;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if radiobutton1.checked then
sqlstr:=sqlstr+'select 姓名 学号 from 学生 where 姓名='+''''+edit1.text+'''';
if radiobutton2.checked then
sqlstr:=sqlstr+'select 姓名 from 学生 where 姓名like'+''''+'%'+edit2.text+'''';
end;
end.