我用delphi 连sqlserver200o 做的程序,,在退出的时候老是出错,什么原因,,自己查了一下,应该跟数据table有关,因为table.active := false ;  table.active:=true; 在子窗体第一次加载的时候没有提示错误,第二次加载就出错。出错以后,再次加载次窗体就没有出错,,在父窗体退出的时候,,table.close ;也不行,,,其中子窗体里面的代码有 tabel.IndexFieldNames :='用户名'  tabel.setkey ;   是不是这个的问题呢???
而在access里面没有这个错误呢??

解决方案 »

  1.   

    子窗口第二次加载出什么错?可以判断一下在。if not table.active = true then
     table.active = ture;
      

  2.   

    procedure TForm5.FormShow(Sender: TObject);
    begin
    orderdata.qx.Active := false ;
    orderdata.qx.Active := true ;
    end ;
    procedure TForm5.Edit2KeyPress(Sender: TObject; var Key: Char);
    begin
    if key =#13 then
     begin
     orderdata.qx.IndexFieldNames :='用户名' ;
     orderdata.qx.SetKey ;
     if orderdata.qx.FindKey([edit1.text]) then
     begin
       if orderdata.qx.FieldByName('密码').AsString =edit2.Text  then
      begin
    ...........
    .......procedure TForm5.FormClose(Sender: TObject; var Action: TCloseAction);
    beginaction:= cafree ;
    end;
    然后form5 ,再次加载的时候出错了,,出错了,再次加载又好了
    FORM5是子窗体,,然后父窗体退出的时候,也出错,,,,
    但是,如果在程序直接运行,马上退出不出错,,如果用FORM5的登陆窗口登陆后,程序退出就出错!!!!我实验了,好像,,就是跟 TABLE有关,,,TABLE.ACTIVE:=FALSE ;TABEL.ACTIVE:=TRUE,不可以重复运行吗???在ACCSESS里面没有错误