Link to home
Start Free TrialLog in
Avatar of henryreynolds
henryreynoldsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

TIBBackupService, cannot attach to service manager

Good day

I am trying to backup my database from Delphi, but I am getting the following error.
cannot attach to service manager.

I read in the help but I am not sure what service component I must add.

Thank you

Henry


var srvBackup : TIBBackupService;
    lOptions  : TBackupOptions;
begin
    srvBackup := TIBBackupService.Create(nil);
    srvBackup.Params.Clear;
    Memo1.Clear;
    Screen.Cursor := crHourGlass;
    try
       srvBackup.Active := true;
       srvBackup.Attach();
       lOptions := [];
 
       if srvBackup.Active = true then
       begin
 
          with srvBackup do
          begin
            ServerName  := 'localhost';
            LoginPrompt := False;
            Params.Add('user_name=sysdba');
            Params.Add('password=masterkey');
            BackupFile.Add('c:\Backup');
            DatabaseName := 'c:\Databases\Database.fd2';
            Verbose := true;
            ServiceStart;
            while not srvBackup.Eof do
            begin
             Application.ProcessMessages;
             Memo1.Lines.Add(srvBackup.GetNextLine)
            end;
          end;
       end;
 
    finally
      if srvBackup.Active then
        srvBackup.Detach();
        Screen.Cursor := crDefault;
    end;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Johnjces
Johnjces
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of henryreynolds

ASKER

Hi John

Sorry but it does not work, it does not open the first service:
SVCManHandle := OpenSCManager('Machine', nil, SC_MANAGER_CONNECT);

What error do you get?

Machine := '' (Null) for your local machine. Do not put in \\Machine.

and Service := your service name...

and in the uses clause make sure you have

uses
 WinSvc;

John

Are you still stuck?

John
Hi John

I only got back at work today, but I think it is something todo with the protocol you must specify.
You can specify LOCAL, TCP or SPX.

I will let you know
Forced accept.

Computer101
EE Admin