with Dmcsdemo.QueryCsDemo do
    begin
       close;
       sql.Clear;
       SQL.Add('use master');
       SQL.Add('restore database test');
       SQL.Add('from disk = ''e:\test''');
       SQL.Add('with recovery');
       execsql;
    end;
运行时提示数据库正在被其他用户使用。大家给看看为什么?

解决方案 »

  1.   

    可能其他程序或线程正在使用.如果真的不行,你干脆把恢复功能做成单独程序,恢复时把主程序close掉。
      

  2.   

    Dmcsdemo.QueryCsDemo不能联那个要恢复的数据库.
    可能强制KILL某个联接啊.Kill 1
      

  3.   

    to  荒地校园
    我做的就是一个单独的程序to  周天
    我连接的不是我要恢复的库
      

  4.   

    不要使用 use master,直接连接到 master 数据库。