Jump to content

Recommended Posts

Posted

Hello guys,

I've created script which is making backup database in MSSQL2012 and using    "_SQL.au3"

But I have a problem with script, it's working well with other database well (1Gb, 35Gb), but with "Test1Database" (250Gb) it doesn't work and giving me error:

""C:\Program Files (x86)\AutoIt3\Include\_SQL.au3" (402) : ==> The requested action with this object has failed.:
$hQuery = $hConHandle.Execute($vQuery)
$hQuery = $hConHandle^ ERROR "

With others databases I've tested my script it's works well but size  significantly smaller (size)  compare to "Test1Database".  The space on disk more than enough.

Can you give a little help with that issue.

My script is bellow:

;*****************************************
;
;*****************************************

#include "_SQL.au3"
#include "Forms\MainForm.isf"

Dim $ObjSQL, $server, $db, $username, $password
$server = "Server name"
$db = "master"
$username = "user"
$password = "pass"
$sqlcod1 = "EXEC [dbo].[ReleaseBackup]"

;
GUISetState(@SW_SHOW, $Mainform)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $idEODButton
            _Button_Click()

            Func _Button_Click()

               $MsgSQL = _SQL_GetErrMsg()

                
                ;------------------------;
                ; Connect to server ;
                ;------------------------;
                
                $ObjSQL = _SQL_Startup()
                

                If $ObjSQL = $SQL_ERROR then Msgbox(0 + 16 + 262144, "Error", _SQL_GetErrMsg())
                
                If _sql_Connect(-1, $server, $db, $username, $password) = $SQL_ERROR then
                    Msgbox(0 + 16 + 262144, "Error", _SQL_GetErrMsg())
                    _SQL_Close()
                    Exit
                EndIf
                

                ;-------------------------------;
                ; Run backup ;
                ;-------------------------------;
                
                $Query1 = ($sqlcod1)
                If _SQL_Execute($ObjSQL,$Query1) =  $SQL_ERROR then
                    Msgbox(0 + 16 + 262144, "Error", _SQL_GetErrMsg())
                EndIf


                If $MsgSQL = "" Then
                  MsgBox(0,"","Succes.")
               Else
                  $MsgSQL = _SQL_GetErrMsg()
                  ErrMsg($MsgSQL)

               EndIf

            EndFunc   ;==>_Button_Click

    EndSwitch
WEnd

 

Posted

HI @Aibek and welcome.

I am just curious... 

$sqlcod1 = "EXEC [dbo].[ReleaseBackup]"

Maybe ReleaseBackup is a "stored procedure" not existant in your "big database" ?

 

Btw and maybe off topic.. usually for backup (and restore) I use a single line like that:

RunWait(@ComSpec & " /c sqlcmd -U user -P password -S yourDBServer -Q  ""backup database " & $DBname & " to disk = '" & $path2db & "backup\" & $DBname & ".dat' "" -o " & $path2db & "backup\log_backup.txt")

Maybe you can try this way.

Sure you can use variables also for user/psw/server.

You will need the SQLCMD utility, if you run the script on the DB server often you already have it in path, otherwise check here

Posted

@Aibek

What COM Error Handler says to you ?

Could you try my ADO.au3 UDF ? 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...