procedure TForm1.FormCreate(Sender: TObject);
begin
with adotable1 do
begin
Open;
while not eof do
begin
combobox1.Items.Add(fieldbyname('name').asstring);
next;
end;
combobox1.Text:=combobox1.Items[0];
close;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
application.Terminate;
end;procedure TForm1.Button1Click(Sender: TObject);
var strpassword:string;
begin
adotable1.DisableControls;
adotable1.Locate('name',combobox1.Text,[lopartialkey]);
strpassword:=adotable1['password'];
adotable1.EnableControls;
if edit1.Text=strpassword then showmessage('成功登录');
end;

解决方案 »

  1.   

    是程序报错了!还是不能成功的执行showmessage啊!
      

  2.   

    strpassword:=adotable1['password'];?
      

  3.   

    Project project1.exe raised exception class EdatabaseError with message 'Adotable1 cannot perform this operation on a closed dataset' prosess stoped. use step or  run to continue
      

  4.   

    提示说的很清楚
    operation on a closed dataset,不能执行操作在关闭的数据集上。
    你的FormCreate最后把那个给关闭掉。
      

  5.   

    改为这样:
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      with adotable1 do
      begin
        Open;
        while not eof do
        begin
          combobox1.Items.Add(fieldbyname('name').asstring);
          next;
        end;
        combobox1.Text:=combobox1.Items[0];
    //    close;这里别急着关闭!
      end;
    end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      application.Terminate;
    end;procedure TForm1.Button1Click(Sender: TObject);
    var strpassword:string;
    begin
      adotable1.DisableControls;
      if adotable1.Locate('name',combobox1.Text,[lopartialkey]) then
      begin
        strpassword:=adotable1['password'];
        if edit1.Text=strpassword then showmessage('成功登录')
        else showmessage('密码错误');
      end
      else showmessage('无此账户');
      adotable1.EnableControls;
    end;
      

  6.   

    adotable1.Locate('name',combobox1.Text,[lopartialkey]);
    参数lopartialkey什么意思?
      

  7.   

    数据库表中还有一个字段'TIMES'用来记录登录的次数,如果要实现达到一定次数不能登录,并显示信息,还要添加哪些代码?
      

  8.   

    不要参数也行if adotable1.Locate('name',combobox1.Text,[])then
      

  9.   

    if adotable1.Locate('name',combobox1.Text,[])then
    这样空着那参数就行了。大家都回了你的问题,怎么不结贴呢?
    这已经不是同一个问题了吧