select 姓名=‘“”+edit1.text+“”’;//精确查找
select 姓名like‘+“”+%edit1.text+“”’;//模糊查找,如输入李,则出现姓李的同学
这样为什么不对呢????、
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;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
if radiobutton1.Checked then
select 姓名 from 学生 '+ ' where 姓名=''' + edit1.Text + '''
else if radiobutton2.Checked then
select 姓名 from 学生 '+ ' where 姓名like''' + %edit2.Text + ''';
end;
end.