我初次学习用Delphi。
我的登录界面的主要代码如下,是按照《Delphi 5数据库开发技术》上的例子来做的:
procedure TfrmLogin.BitBtnOkClick(Sender: TObject);
  var
  pwdfile:textfile;
  pwdstr:string;
  times:integer;
begin
  if checkbox1.Checked=true then
     assignfile(pwdfile,'administrator.cfg')
  else assignfile(pwdfile,'student.cfg');
  reset(pwdfile);
  readln(pwdfile,pwdstr);
  closefile(pwdfile);
  times:=times+1;
  if edtPwd.Text=pwdstr then
    begin
      if checkbox1.Checked=true then frm6.show
      else frm7.show;
    end
  else
    begin
      if messageDlg('password is wrong,quit?',mtConfirmation,[mbYes,mbNo],0)=mrYes then
         close
      else if times<3 then edtPwd.SetFocus
      else messageDlg('fatal password error,please quit',mtInformation,[mbOk],0);
      Application.Terminate;
    end;
end;
可是运行后,delphi给出这样的错误提示;
Project Project1.exe raised exception class EInOutError with message "File not found".Process stopped.Use Step or Run to continue.
意思是我没有那两个.cfg文件。我怎样在那个位置建立这个.cfg文件呢?用Delphi中的过程函数还是自己手工建立?
另外,那个例子中的DataModule窗体是如何创建的?那上面有多个表的数据。而我用Form Wizard来创建DataModule只能是关联一个表。
谢谢你们!

解决方案 »

  1.   

    assignfile(pwdfile,'administrator.cfg')
    没写明文件路径
      

  2.   

    第二个问题我已经知道了。菜单:file---new---在New Item对话框中选择Data Module。然后加入各种数据库的Access控件和Controls控件。第一个问题,我原来用建立文本文件然后另存为的方法试过了,我还有点不相信:这么简单,手工建立就可以了。我以为要用代码在程序里面来建立这个文件呢。To foilsman(刀仔):  为什么用ini呢?能告诉我的原因吗?我记得.ini文件直接就可以用记事本打开的,这样且不是很不安全?还罗嗦一下:用这种方法建立密码登录程序是不是不正式?我在这个论坛搜索了一下,多数是用建立数据库用户表来实现的。请仁兄们点拨一下。
      

  3.   

    To jjpan(皮皮lu):我试了跟指明路径无关。不指明路径,它生成在程序所在的文件夹里面。指明路径了,我认为反而还不太好,要是一旦有文件移动跟指明的路径不同了,就会出错。还是用这样的“相对路径”好。To zyyjc(),你是说这样建立密码登录界面不安全,是吧。少写了一个字。也就是用数据库建立用户密码表来得安全。这就是你说的后台数据库吗?
      

  4.   

    else
        begin
          if messageDlg('password is wrong,quit?',mtConfirmation,[mbYes,mbNo],0)=mrYes then
             close
          else if times<3 then edtPwd.SetFocus
          else messageDlg('fatal password error,please quit',mtInformation,[mbOk],0);请仁兄们再帮着看看,好吗?同时我运行时候发现上面的这段代码有问题。