zotchy Posted November 7, 2011 Share Posted November 7, 2011 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? Link to comment Share on other sites More sharing options...
wraithdu Posted November 7, 2011 Share Posted November 7, 2011 (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 November 7, 2011 by wraithdu Link to comment Share on other sites More sharing options...
Zedna Posted November 7, 2011 Share Posted November 7, 2011 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. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
zotchy Posted November 9, 2011 Author Share Posted November 9, 2011 (edited) This the part of script. Not full, because it is very big: expandcollapse popup#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 November 9, 2011 by zotchy Link to comment Share on other sites More sharing options...
water Posted November 9, 2011 Share Posted November 9, 2011 (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 November 9, 2011 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 Link to comment Share on other sites More sharing options...
zotchy Posted November 9, 2011 Author Share Posted November 9, 2011 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. Link to comment Share on other sites More sharing options...
water Posted November 9, 2011 Share Posted November 9, 2011 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 Link to comment Share on other sites More sharing options...
zotchy Posted November 9, 2011 Author Share Posted November 9, 2011 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. Link to comment Share on other sites More sharing options...
Zedna Posted November 9, 2011 Share Posted November 9, 2011 This error is not from your COM error handler. Try to test @error after ObjCreate() Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted November 9, 2011 Share Posted November 9, 2011 $conn.close Also this is safe way how to do closing: If IsObj($conn) And $conn.State > 0 Then $conn.Close Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
zotchy Posted November 9, 2011 Author Share Posted November 9, 2011 Zedna,I added:$conn = ObjCreate("ADODB.Connection")@error Also I changed connection closure line.The message is the same. Link to comment Share on other sites More sharing options...
zotchy Posted November 9, 2011 Author Share Posted November 9, 2011 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. Link to comment Share on other sites More sharing options...
wraithdu Posted November 9, 2011 Share Posted November 9, 2011 So you ignored what I said in post #2 then? Good to know. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now