当前位置:编程学习 > Delphi >>

delphi问题

unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls;

type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADOQuery1: TADOQuery;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
Button2: TButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation
uses unit2;
{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
begin
Application.Terminate;//退出系统
end;

procedure TForm1.Button1Click(Sender: TObject);
var username ,password:string;
begin
if edit1.Text=''then
messagebox(Form1.Handle,'请输入用户名','警告',mb_ok+mb_iconwarning)
else
if edit1.Text=''then
messagebox(Form1.Handle,'请输入密码','警告',mb_ok+mb_iconwarning)
else
begin
username:=edit1.Text ;
password:=edit2.Text;
with ADOQuery1 do
begin
close;
sql.Clear;
sql.add('select*from 用户管理 where username=');
open;
first;
if recordcount=1 then
begin
Form1.Hide;
Form2.Show;
end
else
messagebox(Form1.Handle,'请输入用户名','警告',mb_ok+mb_iconwarning) ;


end;
end;

end;
[错误] Unit1.pas(96): Declaration expected but end of file found
[致命错误] Project1.dpr(5): Could not compile used unit 'Unit1.pas'
谢谢了,在线等
补充:修改了一下,只剩一个错误了[错误] Project1.dpr(6): ',' or ';' expected but identifier 'Unit2' found
		
答案:
新电脑上没有装delphi不好测试!
但用眼睛看了一下,这里有错误if edit1.Text=''then
应该空一格
if edit1.Text='' then
SQL也要注意空格啊:
sql.add('select*from 用户管理 where username=');
应该是:
sql.add('select * from 用户管理 where username=');
并且这句SQL也写得有问题啊,查询条件为空
答案补充
如果复制完代码的话,程序最后还差个end.
我还没学到这里`
对不起 帮不了你+
看看你的单元文件unit2中是否有',' or ';' ,这个不能是全角,要用英文输入的,是不是从网上直接copy的代码,这样的符号都是带格式的.
Unit2中的SQL语句问题,把语句打印出来放到数据库执行下就很快找到原因了
你确定代码都贴上来了吗?
好像就是最后缺少一句
end.
加上就好了

上一个:ord delphi
下一个:delphi问题

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,