Sign in to follow this  
Followers 0

Unable to run compiled *.exe script on another PC

13 posts in this topic

#1 ·  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?

Share this post


Link to post
Share on other sites



#2 ·  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

Share this post


Link to post
Share on other sites

#3 ·  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.

Share this post


Link to post
Share on other sites

#4 ·  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

Share this post


Link to post
Share on other sites

#5 ·  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:

UDFs:
Active Directory (NEW 2015-08-07 - Version 1.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (NEW 2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#6 ·  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.

Share this post


Link to post
Share on other sites

#7 ·  Posted

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


My UDFs and Tutorials:

UDFs:
Active Directory (NEW 2015-08-07 - Version 1.2.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2014-07-27 - Version 1.0.0.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (NEW 2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
Tutorials:
ADO - Wiki

Share this post


Link to post
Share on other sites

#8 ·  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

Share this post


Link to post
Share on other sites

#9 ·  Posted

This error is not from your COM error handler.

Try to test @error after ObjCreate()

Share this post


Link to post
Share on other sites

#10 ·  Posted

$conn.close

Also this is safe way how to do closing:

If IsObj($conn) And $conn.State > 0 Then $conn.Close

Share this post


Link to post
Share on other sites

#11 ·  Posted

Zedna,

I added:

$conn = ObjCreate("ADODB.Connection")

@error

Also I changed connection closure line.

The message is the same.

Share this post


Link to post
Share on other sites

#12 ·  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.

Share this post


Link to post
Share on other sites

#13 ·  Posted

So you ignored what I said in post #2 then? Good to know.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0