Backup and Restore in Delphi with Sql Server how to do?

Asked

Viewed 901 times

0

Hello I would like to know how I can do a Backup and Restore to integrate in my system. I have a code ready but is for Firebird I believe that does not fit to Sql Server. I read in some topics that there are no components for Backup and Restore with Sql Server in Delphi, the only ways to do it would be via line of code, in another article I found something about doing a database process and call - la in Delphi. My big problem is that I’ve never done a database trial and it’s not really my specialty database. Finally I wonder if you can give me a help to develop a Backup and Restore to Delphi system using Sql Server 2012

  • What do you mean, you want to backup and Restore but it’s not your specialty Database? It’s time to expand your specialties.

  • Yes, I am expanding, but I come from the web environment where my function almost never connected with database, now in the desktop environment I am always in contact and I am expanding. But what I described in the question for example, is something new for me.

1 answer

1

procedure TBackupRestore.BtnBackUpClick(Sender: TObject);
var
  ADOCommand : TADOCommand;
  CLIENTE : String;
begin

  CLIENTE := 'teste';

  ADOCommand := TADOCommand.Create(nil); //Cria o objeto de comando para executar a rotina de backup do SQL SERVER 2000
  with ADOCommand do begin
    //ADOCommand.Name := 'ADOGeraBackup'; //Nome do objeto
    ADOCommand.ConnectionString := ADOConnection1.ConnectionString; //Cria a conexão com o Provider do SQL Server
    //ADOCommand.CommandType := cmdText; //Define como command Text para execução de linhas de comando
    ADOCommand.CommandText := 'BACKUP DATABASE '+CLIENTE+' TO DISK =''c:\SQLBackUp\sql.bak''';
    ADOCommand.Execute; //Executa a linha de comando
  end;

end;

Restore will be similar, but you will have to work a code to run first in a test table, go to work, but if you break your head I believe you can !

Browser other questions tagged

You are not signed in. Login or sign up in order to post.