unit user_inf_out;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, Grids, DBGrids, StdCtrls, Mask, DBCtrls, ExtCtrls;type
TForm5 = class(TForm)
Label1: TLabel;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
ADOTable1: TADOTable;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
Edit1: TEdit;
Button1: TButton;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
Label2: TLabel;
RadioButton4: TRadioButton;
procedure Button1Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
procedure RadioButton4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form5: TForm5;implementationuses main;{$R *.dfm}procedure TForm5.Button1Click(Sender: TObject);
var
str1,strsql:string;
begin
if RadioButton4.Checked=true then
begin
Edit1.Enabled:=true;
strsql:='select * from 用户基本信息';
with ADOTable1 do
begin
close;
SQL.Clear;
SQL.Add(strsql);
open;
if ADOTable1.RecordCount = 0 then
begin
MessageBox(self.Handle, '数据库为空!', '提示', mb_IconInformation + mb_Ok);
end;
end;end;
if Edit1.Text<>'' then
begin
if RadioButton1.Checked=true then
begin
Edit1.Enabled :=true;
str1:=edit1.Text;
strsql:='select * from 用户基本信息 where 工号='''+str1+'''';
with ADOTable1 do
begin
close;
SQL.Clear;
SQL.Add(strsql);
open;
if ADOTable1.RecordCount = 0 then
begin
MessageBox(self.Handle, '无此信息,请确认您输入的信息是否正确!', '提示', mb_IconInformation + mb_Ok);
end;
end;
end;
end;
if Edit1.Text<>'' then
begin
if RadioButton2.Checked=true then
begin
Edit1.Enabled :=true;
str1:=edit1.Text;
strsql:='select * from 用户基本信息 where 姓名='''+str1+'''';
with ADOTable1 do
begin
close;
SQL.Clear;
SQL.Add(strsql);
open;
if ADOTable1.RecordCount = 0 then
begin
MessageBox(self.Handle, '无此信息,请确认您输入的信息是否正确!', '提示', mb_IconInformation + mb_Ok);
end;
end;
end;
end;
if Edit1.Text<>'' then
begin
if RadioButton3.Checked=true then
begin
str1:=edit1.Text;
strsql:='select * from 用户基本信息 where 部门='''+str1+'''';
with ADOTable1 do
begin
close;
SQL.Clear;
SQL.Add(strsql);
open;
if ADOTable1.RecordCount = 0 then
begin
MessageBox(self.Handle, '无此信息,请确认您输入的信息是否正确!', '提示', mb_IconInformation + mb_Ok);
end;
end;
end;
end
else
begin
if (edit1.Showing =true) then
begin
MessageBox(self.Handle, '请输入查询条件!', '提示', mb_IconInformation + mb_Ok);
if (edit1.Showing =true) then
edit1.SetFocus;
end;
end;
end;procedure TForm5.RadioButton1Click(Sender: TObject);
begin
Button1.Enabled :=true;
Edit1.Show ;
label2.Caption:='请输入要查询的工号';
edit1.SetFocus ;
end;procedure TForm5.RadioButton2Click(Sender: TObject);
begin
Button1.Enabled :=true;
Edit1.Show ;
label2.Caption:='请输入要查询的姓名';
edit1.SetFocus ;
end;procedure TForm5.RadioButton3Click(Sender: TObject);
begin
Button1.Enabled :=true;
Edit1.Show ;
label2.Caption:='请输入要查询的部门名称';
edit1.SetFocus ;
end;procedure TForm5.RadioButton4Click(Sender: TObject);
begin
Button1.Enabled :=true;
label2.Caption :='';
edit1.Hide;
end;end.
调试结果:[Error] user_inf_out.pas(55): Undeclared identifier: 'SQL'
[Error] user_inf_out.pas(56): Missing operator or semicolon
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, Grids, DBGrids, StdCtrls, Mask, DBCtrls, ExtCtrls;type
TForm5 = class(TForm)
Label1: TLabel;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
ADOTable1: TADOTable;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
Edit1: TEdit;
Button1: TButton;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
Label2: TLabel;
RadioButton4: TRadioButton;
procedure Button1Click(Sender: TObject);
procedure RadioButton1Click(Sender: TObject);
procedure RadioButton2Click(Sender: TObject);
procedure RadioButton3Click(Sender: TObject);
procedure RadioButton4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form5: TForm5;implementationuses main;{$R *.dfm}procedure TForm5.Button1Click(Sender: TObject);
var
str1,strsql:string;
begin
if RadioButton4.Checked=true then
begin
Edit1.Enabled:=true;
strsql:='select * from 用户基本信息';
with ADOTable1 do
begin
close;
SQL.Clear;
SQL.Add(strsql);
open;
if ADOTable1.RecordCount = 0 then
begin
MessageBox(self.Handle, '数据库为空!', '提示', mb_IconInformation + mb_Ok);
end;
end;end;
if Edit1.Text<>'' then
begin
if RadioButton1.Checked=true then
begin
Edit1.Enabled :=true;
str1:=edit1.Text;
strsql:='select * from 用户基本信息 where 工号='''+str1+'''';
with ADOTable1 do
begin
close;
SQL.Clear;
SQL.Add(strsql);
open;
if ADOTable1.RecordCount = 0 then
begin
MessageBox(self.Handle, '无此信息,请确认您输入的信息是否正确!', '提示', mb_IconInformation + mb_Ok);
end;
end;
end;
end;
if Edit1.Text<>'' then
begin
if RadioButton2.Checked=true then
begin
Edit1.Enabled :=true;
str1:=edit1.Text;
strsql:='select * from 用户基本信息 where 姓名='''+str1+'''';
with ADOTable1 do
begin
close;
SQL.Clear;
SQL.Add(strsql);
open;
if ADOTable1.RecordCount = 0 then
begin
MessageBox(self.Handle, '无此信息,请确认您输入的信息是否正确!', '提示', mb_IconInformation + mb_Ok);
end;
end;
end;
end;
if Edit1.Text<>'' then
begin
if RadioButton3.Checked=true then
begin
str1:=edit1.Text;
strsql:='select * from 用户基本信息 where 部门='''+str1+'''';
with ADOTable1 do
begin
close;
SQL.Clear;
SQL.Add(strsql);
open;
if ADOTable1.RecordCount = 0 then
begin
MessageBox(self.Handle, '无此信息,请确认您输入的信息是否正确!', '提示', mb_IconInformation + mb_Ok);
end;
end;
end;
end
else
begin
if (edit1.Showing =true) then
begin
MessageBox(self.Handle, '请输入查询条件!', '提示', mb_IconInformation + mb_Ok);
if (edit1.Showing =true) then
edit1.SetFocus;
end;
end;
end;procedure TForm5.RadioButton1Click(Sender: TObject);
begin
Button1.Enabled :=true;
Edit1.Show ;
label2.Caption:='请输入要查询的工号';
edit1.SetFocus ;
end;procedure TForm5.RadioButton2Click(Sender: TObject);
begin
Button1.Enabled :=true;
Edit1.Show ;
label2.Caption:='请输入要查询的姓名';
edit1.SetFocus ;
end;procedure TForm5.RadioButton3Click(Sender: TObject);
begin
Button1.Enabled :=true;
Edit1.Show ;
label2.Caption:='请输入要查询的部门名称';
edit1.SetFocus ;
end;procedure TForm5.RadioButton4Click(Sender: TObject);
begin
Button1.Enabled :=true;
label2.Caption :='';
edit1.Hide;
end;end.
调试结果:[Error] user_inf_out.pas(55): Undeclared identifier: 'SQL'
[Error] user_inf_out.pas(56): Missing operator or semicolon
begin
close;
SQL.Clear;
SQL.Add(strsql);
open;
if ADOTable1.RecordCount = 0 then
begin
MessageBox(self.Handle, '数据库为空!', '提示', mb_IconInformation + mb_Ok);
end;
end; end; ADOTable1没有sql属性
2user_inf_out.pas(56): Missing operator or semicolon ,
不知道56行在哪,最好你定位一下,我们才好看错误