为什么保存可以,我用逐步调试,打开也可以,可是为什么
CopyFile(openFile,newFile, false); 执行后没有经过,也就是没有用,谢谢,

解决方案 »

  1.   

    if openDialog1.Execute then
       begin
       self.openDialog1.InitialDir:='d:\PHS_SYSTEM\PHS.MDB';
       if self.openDialog1.FileName='' then exit  else
          begin
          openfile:=pchar(self.openDialog1.filename+'.MDB') ;
          newfile:='D:\PHS_SYSTEM\PHS.MDB';
          CopyFile(openFile,newFile, false);
          end;
       end;逐步调试,没错,追后COPYFILE 没有 newfile:='D:\PHS_SYSTEM\PHS.MDB';
       为已经连接好的数据库,而我希望被OPENFILE覆盖
      

  2.   


    if openDialog1.Execute then
       begin
       self.openDialog1.InitialDir:='d:\PHS_SYSTEM\PHS.MDB';
       if self.openDialog1.FileName='' then exit  else
          begin
          openfile:=pchar(self.openDialog1.filename+'.MDB') ;
          newfile:='D:\PHS_SYSTEM\PHS.MDB';
    ////////////////Debug/////////////////////
           ShowMessage(OpenFile);
           ShowMessage(NewFile);
           if not FileExists(OpenFile) then
             ShowMessage('源文件不存在,所以出错!')
           if FileExists(NewFile) then
             ShowMessage('还有可能是目标文件已经存在');
    ////////////////Debug/////////////////////       
          CopyFile(openFile,newFile, false);
          end;
       end;
      

  3.   

    没用,CopyFile(openFile,newFile, false); 也通的过,可是错在没有结果,
    我的 newfile:='D:\PHS_SYSTEM\PHS.MDB'; 已经用ODBC连好了,是不是不行
      

  4.   

    if not FileExists(OpenDialog1.FileName) then Exit;openfile:=pchar(self.openDialog1.filename{+'.MDB'}); //不要加".MDB"
      

  5.   

    谢谢,我试过了,不加MDB,没用,
    主要不能覆盖
      

  6.   

    将OpenDialog的扩展名设置为.MDB,openfile:=pchar(self.openDialog1.filename{+'.MDB'}); //不要加".MDB"
      

  7.   

    procedure ShowLastError;
    var
      MessageStr: string;
      Size: Integer;
    begin
      Size := 256;
      SetLength(Messagestr, Size);
      Size := FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
                            nil,
                            GetLastError,
                            0,
                            PChar(MessageStr),
                            Size,
                            nil);
      SetLength(MessageStr, Size - 2);
      ShowMessage(MessageStr);
    end;
    ...
    if Not CopyFile(openFile,newFile, false) then
      ShowLastError;
      

  8.   

    不加MDB,或加,我都试过了,用SHOWMESSAGE()查看,关键是
    好象覆盖不了 ,
      

  9.   

    procedure ShowLastError;
    var
      MessageStr: string;
      Size: Integer;
    begin
      Size := 256;
      SetLength(Messagestr, Size);
      Size := FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
                            nil,
                            GetLastError,
                            0,
                            PChar(MessageStr),
                            Size,
                            nil);
      SetLength(MessageStr, Size - 2);
      ShowMessage(MessageStr);
    end;....if Not CopyFile(openFile,newFile, false) then
      ShowLastError;
      

  10.   

    CopyFile(openFile,newFile, True); //false -> True
      

  11.   

    ---------------------------
    Phs
    ---------------------------
    其他进程正使用该文件,
    因此现在无法访问。
    ---------------------------
    OK   
    ---------------------------怎么办呢,
      

  12.   

    CopyFile(openFile,newFile, True); //false -> True
      

  13.   

    我本来的意思就是连好了,然后我可以调用各位兄弟,我可以多给分,我想打开SAVE里的,但不知道如何,就很土,用原来的覆盖现在已经连接好的,
    有别的办法打开保存的数据库吗,
      

  14.   

    try to terminate connection first
      

  15.   

    我把DATABASE 都短了CONNECT,
    不过我的ODBC 连在刚才
      self.openDialog1.InitialDir:='d:\PHS_SYSTEM\PHS.MDB';
    也就是在我要保存的地方,