TMSDump Example

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Jerbear
Posts: 13
Joined: Sun 02 Nov 2008 10:33
Location: Ireland

TMSDump Example

Post by Jerbear » Thu 13 Oct 2016 14:31

Hi Guys.
I can use this to backup a chosen database but can do nothing else until backup is complete
and there is no indication on screen that a backup is taking place.

Code: Select all

  
  BakUpFile := 'C:\MYBACKUPS\MYDATA.BAK';
  MyQuery.SQL.Clear;
  BakUpQuery := 'BACKUP DATABASE ['+DBName+'] TO  DISK = N'''+BakUpFile+'''';
  MyQuery.SQL.Add(BakUpQuery);
  MyQuery.Execute;
  
I'm told that TMSDump might be what I'm looking for but have no idea how to translate
the above code to work with TMSDump. Anyone help me out here please....

LHSoft
Posts: 100
Joined: Sat 18 Aug 2012 08:33

Re: TMSDump Example

Post by LHSoft » Fri 14 Oct 2016 00:15

try:
TMSConnection.OnInfoMessage

best regards
hans

Jerbear
Posts: 13
Joined: Sun 02 Nov 2008 10:33
Location: Ireland

Re: TMSDump Example

Post by Jerbear » Fri 14 Oct 2016 09:59

Sorry LHSoft,
but I have no clue what to do with that.
looked it up in the docs as well and it didn't help.
Did I mention I was a NEWBIE at this......????

LHSoft
Posts: 100
Joined: Sat 18 Aug 2012 08:33

Re: TMSDump Example

Post by LHSoft » Fri 14 Oct 2016 10:14

Just Try it:

Code: Select all

procedure TMSConnectionInfoMessage(Sender: TObject; E: EDAError);
begin
   ShowMessage(E.Message);
end;
and then let your application react on e.message

Jerbear
Posts: 13
Joined: Sun 02 Nov 2008 10:33
Location: Ireland

Re: TMSDump Example

Post by Jerbear » Mon 17 Oct 2016 07:33

Morning Hans,
Sorry but I think you must have missed the part where I said I was a NEWBIE.

It's not much help I'm afraid without some serious explanation and my original question was related to the TMSDump Function/Procedure...

regards
Jer.

azyk
Devart Team
Posts: 1010
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TMSDump Example

Post by azyk » Mon 17 Oct 2016 12:31

In order to display the backup execution progress in the user application, in T-SQL command BACKUP DATABASE, set a value, such as 10, for option STATS. Now, during the execution of each 10% of backup, SDAC will receive info messages from SQL Server, which can be processed in the TMSConnection.OnInfoMessage event handler. To do this, in the code you provided, replace the line

Code: Select all

BakUpQuery := 'BACKUP DATABASE ['+DBName+'] TO  DISK = N'''+BakUpFile+'''';
with

Code: Select all

BakUpQuery := 'BACKUP DATABASE ['+DBName+'] TO  DISK = N'''+BakUpFile+'''' + ' WITH STATS = 10;';
For more information on BACKUP DATABASE, please refer to MSDN: https://msdn.microsoft.com/en-us/library/ms186865.aspx
The TMSDump component is used to create a T-SQL script of a backup - it does not allow to create a backup in bak format of SQL Server. For more information on TMSDump, please refer to our online documentation: https://www.devart.com/sdac/docs/?devar ... msdump.htm

Jerbear
Posts: 13
Joined: Sun 02 Nov 2008 10:33
Location: Ireland

Re: TMSDump Example

Post by Jerbear » Mon 17 Oct 2016 14:30

Many thanks.
That's easier to understand.
Will give this a try later today...

Regards
Jerry

Post Reply