Jump to content

Recommended Posts

Posted

Hello,

I have a problem with running of compiled *.exe script on another PC.

This issue appears after adding following code:

If $msg = $button Then
   $output = ''
   $conn = ObjCreate("ADODB.Connection")
   $DSN = "DRIVER={SQL Server};SERVER=name;DATABASE=name;UID=name;PWD=pass;Trusted_Connection=False;"
   $conn.Open($DSN)
   $rs = ObjCreate( "ADODB.RecordSet" )
   $rs.Open( "select * from x", $conn )
   if $rs.RecordCount Then
    while not $rs.EOF
     $output &= $rs.Fields(0).Value & ' '& $rs.Fields(1).Value & @CRLF
     $rs.MoveNext
    WEnd
   EndIf
   GUICtrlSetData($editgui, $output)
   $conn.close
EndIf

This script connects to SQL server, recieve data and send to Edit control GUI.

This script is running fine in *.au3. It's running fine in compiled *.exe status. But only on PC where I developed it.

When I try to run it on different PC it shows following: "Error: The requested action with object has failed.". I was trying to add error handler but it didn't show me anything in *.exe build. Only provided message.

Did I miss something? I thought compiled script should contains all required functions and libraries. No?

Posted (edited)

You'll have to debug a bit more (line by line, check status of objects, etc), but I would guess your other PC is having trouble creating the ADODB.Connection object, or is having trouble connecting to the database for some reason (since you are not checking if $conn.Open is successful). If so, that is not AutoIt's fault.

Edited by wraithdu
Posted

When I try to run it on different PC it shows following: "Error: The requested action with object has failed.". I was trying to add error handler but it didn't show me anything in *.exe build. Only provided message.

Post your script with error handler. If it's correctly written then it will say exact error text.

Also check if server/database have the same name as on your PC.

Posted (edited)

This the part of script. Not full, because it is very big:

#include <GUIConstantsEx.au3>
#include <TreeViewConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>

;------------handler---
Func MyErrFunc()
  $hexnum=hex($objErr.number,8)
  Msgbox (0,"","We intercepted a COM Error!!"     & @CRLF               & @CRLF & _
             "err.description is: " & $objErr.description   & @CRLF & _
             "err.windescription is: " & $objErr.windescription & @CRLF & _
             "err.lastdllerror is: "   & $objErr.lastdllerror   & @CRLF & _
             "err.scriptline is: "   & $objErr.scriptline   & @CRLF & _
             "err.number is: "     & $hexnum               & @CRLF & _
             "err.source is: "     & $objErr.source     & @CRLF & _
             "err.helpfile is: "       & $objErr.helpfile     & @CRLF & _
             "err.helpcontext is: " & $objErr.helpcontext _
    )
  exit
EndFunc


;------------------connection------
If $msg = $runbacklog_rus Then
   $output = ''
   $conn = ObjCreate("ADODB.Connection")
   $DSN = "DRIVER={SQL Server};SERVER=srv;DATABASE=db;UID=user;PWD=pass;Trusted_Connection=False;"
   $conn.Open($DSN)
   $rs = ObjCreate( "ADODB.RecordSet" )
   $rs.Open( "[select]", $conn )
   if $rs.RecordCount Then
    while not $rs.EOF
     $output &= $rs.Fields(0).Value & ' '& $rs.Fields(1).Value & @CRLF
     $rs.MoveNext
    WEnd
   EndIf
   GUICtrlSetData($backlog_gui, $output)
   $conn.close
EndIf

The script was working fine before I add ADODB.Connection objects

The server/DB names are the same on each PC.

Edited by zotchy
Posted (edited)

Is the line

$objErr = ObjEvent("AutoIt.Error","MyErrFunc")
somewhere in your script (should be on top of your code)?

If this line is missing then the error handler will never be called!

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

Is the line

$objErr = ObjEvent("AutoIt.Error","MyErrFunc")
somewhere in your script (should be on top of your code)?

If this line is missing then the error handler will never be called!

I am sorry. Of course, I have $objErr = ObjEvent("AutoIt.Error","MyErrFunc") just above the handler.
Posted

Great, can you post a screenshot of the MsgBox you get?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Posted

We have here the error line, but I do not have line with such number. During compilation it compiles all libraries which I use in script. So it is very hard to determine exact line.

Posted Image

Posted

Dear Zedna,

Thank you very much for your help. I think I know what this issue about. It is all about connection. Not with server but with creadentials. The SQL is using Windows Authentification. And it is not possible to use connection under another account(((. That's why script returns error.

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...