我用的是delphi7开发一个才c/s结构的一个小系统。由于是初学者,有些问题亟待解决。我用的是remote服务器midas多层应用程序。但我在有运行登录窗体时他报错:
project server1.exe raised exception class EAccessViolation with message'Access violation at adrress 00575200 in module'server1.exe.Read of address 00000060'.Process stopped.Use Step or Run to continue.
他指向的位置是
procedure TfrmLogin.btnOkClick(Sender: TObject);
var
  username, password: string;
begin
  username := edtusername.Text;
  password := edtpassword.Text;
  try
    dmclient.cdsLogin.Active := false;
    {dmclient.cdsLogin.CommandText:='select *from systemusers'+
  'where username:=username and password=:password';}
  //向应用服务器传递参数值,以便进行查询
    dmclient.cdsLogin.Params.ParamByName('username').Value := username;
    dmclient.cdsLogin.Params.ParamByName('password').Value := password;
    dmclient.cdsLogin.Open;
  //查到唯一用户
    if dmclient.cdsLogin.RecordCount=1 then
    begin
  //取得用户权限
      formMain.authorization:= dmclient.cdsLogin.fieldbyname('authorization').Value;
      flag := true;
      close;
    end
    else
    begin
      flag:=false;
      messagedlg('用户验证失败', mterror, [mbok], 0);
      exit;
    end;
  except
    on e:exception do
    begin
      messagedlg('错误:' + e.Message, mterror, [mbok], 0);
      exit;
    end;
  end;
end;
谁能帮我看一下呀,我在线等待,我都搞了两天这个错误了。大哥们救救我呀。

解决方案 »

  1.   

    运行到这里的时候 dmClient窗体创建了么?
      

  2.   

    dmclient窗体放在 autocreateform里还是放在 available里面
      

  3.   

    无所谓,断点设置在这句,看dmclient是不是nil就知道了。
      

  4.   

    但我在工程里面创建了dmclient了呀
      

  5.   

    要不还是在dmclient.cdsLogin.Active := false; 
    上面加上dmclient:=Tdmclient.create(Self);
    这样不行
      

  6.   

    你看看工程的pas文件里dmclient和frmlogin是谁先创建的
      

  7.   

    我刚才又检查了一下,发现不只是登录窗体会出现这个错误,所有访问服务器的窗体都会出现类似错误。错误都发生在
    clientdataset上面
      

  8.   

    你客户端工程名是Server1?