我做了个登录界面上面有两个button 两个edit 一个SQLQuery1控件 一个SQLConnection1控件(连接正常)代码如下
procedure TForm4.entryClick(Sender: TObject);
var
str,str1: string;
begin
str1:=trim(edit1.Text);
str:=trim(edit2.Text);
SQLQuery1.Locate('name', str1, []);
if trim(SQLQuery1.fieldbyname('name').AsString )=str1 then
begin
if trim(SQLQuery1.fieldbyname('password').AsString )=str then
begin
ModalResult := 1;
success := True;
end
else
begin
MessageDlg('对不起,密码错误,你无权进入系统!', mtError, [mbOK], 0);
ModalResult := 0;
end;
end;
end;工程代码如下:begin
Application.Initialize;
Application.CreateForm(Tform4, form4); //登录窗口
if form4.ShowModal = 1 then
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1); //主窗口运行
Application.CreateForm(TForm3, Form3);
Application.CreateForm(TDataModule1, DataModule1);
Application.CreateForm(TForm5, Form5);
Application.CreateForm(TForm7, Form7);
end;
form4.Free;
application.Terminate ;
Application.Run ;
end.
但是输入正确的用户名和密码后 点击确定 系统自动结束了 无法进入到主界面 请问代码错在哪里了?
procedure TForm4.entryClick(Sender: TObject);
var
str,str1: string;
begin
str1:=trim(edit1.Text);
str:=trim(edit2.Text);
SQLQuery1.Locate('name', str1, []);
if trim(SQLQuery1.fieldbyname('name').AsString )=str1 then
begin
if trim(SQLQuery1.fieldbyname('password').AsString )=str then
begin
ModalResult := 1;
success := True;
end
else
begin
MessageDlg('对不起,密码错误,你无权进入系统!', mtError, [mbOK], 0);
ModalResult := 0;
end;
end;
end;工程代码如下:begin
Application.Initialize;
Application.CreateForm(Tform4, form4); //登录窗口
if form4.ShowModal = 1 then
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1); //主窗口运行
Application.CreateForm(TForm3, Form3);
Application.CreateForm(TDataModule1, DataModule1);
Application.CreateForm(TForm5, Form5);
Application.CreateForm(TForm7, Form7);
end;
form4.Free;
application.Terminate ;
Application.Run ;
end.
但是输入正确的用户名和密码后 点击确定 系统自动结束了 无法进入到主界面 请问代码错在哪里了?
解决方案 »
- ??? ShellList 右键选择文件夹时,如何使用自己的右键菜单 ???
- 求助:ListView_GetSubItemRect 在Delphi中编译报错:Undeclared identifier: 'ListView_GetSubItemRect'
- 是不是delphi有问题,怎么这个小地方过不去呢,帮看一下
- 问一个关于10022的奇怪问题
- 关于DevExpress控件
- quick报表打印的问题,UP有分
- 数据源
- AdvStringGrid能做多表头吗?100分
- 表表插入问题,请高手指教
- 关于Locate问题
- 如何动态获取网页中一个图片的地址?
- 求助fastreport怎样做不定列数的报表
form4:=TForm4.Create(application);
try
if form4.ShowModal=1 then
//...;
finally
form4.free;
end;
Application.Initialize;
Application.CreateForm(TLOGIN, LOGIN);
Application.Run;执行的时候跟踪一下会发现,Application.Run运行之后LOGIN窗体才出现。
你代码的这种写法我没发理解。可不可以用其他的方法,在确定按钮里写代码让主窗体运行。