这个窗体的主要功能是 在EDIT中输入一个线路 点击查询按钮 在DBGRID中显示查询结果 我这个系统中另一个窗体功能和这个几乎一样 所以我复制了那里的代码过来 可是到了这个窗体运行就报如下错误 :[错误] Unit2.pas(60): ';' not allowed before 'ELSE'
[严重错误] Unit2.pas(7): Could not compile used unit 'Unit2'
-------------------------------------------------------unit Unit2;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Unit3,StdCtrls, ExtCtrls, DBCtrls, Grids, DBGrids, DB, ADODB;type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
DBGrid1: TDBGrid;
DBNavigator1: TDBNavigator;
Edit1: TEdit;
Button3: TButton;
ADOConnection2: TADOConnection;
DataSource2: TDataSource;
ADOTable2: TADOTable;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form2: TForm2;implementation
uses unit1;
{$R *.dfm}procedure TForm2.Button1Click(Sender: TObject);
begin
Form1.Show;
Form2.Hide;
end;procedure TForm2.Button2Click(Sender: TObject);
begin
Form1.Hide;
Form2.Hide;
Form3.show;end;procedure TForm2.Button3Click(Sender: TObject);
begin
ADOTable2.IndexFieldNames:='车次';
If ADOTable2.Locate('车次',Edit1.Text,[])
then label2.Caption:='';
else label2.Caption:='您输入的站点不存在,请重新输入';
end;
end.
else label2.Caption:='您输入的站点不存在,请重新输入';else之前是不能有";" 的,哈哈,记得了
因为这个所以就不能编译了 :: [严重错误] Unit2.pas(7): Could not compile used unit 'Unit2'