View Single Post
 
Old 03-27-2018, 09:36 AM
rmt rmt is offline
Senior Member
 
Join Date: Jun 2013
Posts: 280
Default

Dear Expert,

Thanks for all help. But I coded as below and worked as desired.

HTML Code:
procedure TfrmVerifyDataBackup.btnVerifyClick(Sender: TObject);
//var n:Integer;
var cmd: _Command;
    Conn: _Connection;
    Pars: Parameters;
    RA: OleVariant;
    n: Integer;
 WindowsUser,MBUdlName:String;
begin

Memo1.Clear;

        Conn:= CreateComObject (CLASS_Connection) as _Connection;

        WindowsUser:=GetUserFromWindows;
        if FileExists(DataLinkDir+'\Connection.Config') then
                MBUdlName:=WindowsUser+'.udl'
        else
                MBUdlName :='Microbanker.udl';

        Conn.ConnectionString :=format('FILE NAME=%S\'+MBUdlName,[DataLinkDir]);

        Conn.Open(Conn.ConnectionString, '' , '' , Integer (adConnectUnspecified));

        cmd:= CreateComObject (CLASS_Command) as _Command;
        cmd.CommandType:= adcmdText;//adCmdStoredProc;
        cmd.Set_ActiveConnection (Conn);
        Pars:= cmd.Parameters;
        Pars.Append (cmd.CreateParameter ( '@RETURN' , adInteger, adParamReturnValue, 4 , 0 ));

        cmd.CommandText:='restore verifyonly from disk ='+QuotedStr(editPath.Text);
        //cmd.Execute (RA, Pars, Integer (adCmdStoredProc));
        cmd.Execute(RA,Pars,Integer(adcmdText));

        for n:= 0 to (Conn.Errors. Count - 1 ) do
        begin
                Memo1.Lines.Add (Conn.Errors.Item [n] .Description);
        end ;

        cmd.Set_ActiveConnection (nil);
        Conn.Close;
        Pars:= nil;
        cmd:= nil;
        Conn:= nil;
end;
Thanks..
__________________
Rmt