BigDaddyO Posted July 30, 2015 Posted July 30, 2015 (edited) Just upgraded to the new versionI have some problems with a couple databases getting record counts back from queries so I started just getting the value of a Primary Key ID and if > 0 then there were records returned.With this new version, the script bombs when no record was returned. Here is an example I put together. The Table does not have any Text1 = 'ABC' so the Returned ID value was empty, but now I get the following error:"H:\My Scripts\AutoIT-3\Database Stuff\Get Data from Access Database.au3" (14) : ==> The requested action with this object has failed.:if .Fields("ID").Value > 0 Thenif .Fields("ID")^ ERROR $sTargetDB = "C:\Temp\Database.accdb" $Conn = ObjCreate("ADODB.Connection") $Conn.open("Provider=Microsoft.ACE.OLEDB.12.0; Data Source=" & $sTargetDB) $adoRs = ObjCreate ("ADODB.Recordset") $adoRs.CursorType = 2 $adoRs.LockType = 3 $sSQL = "Select * from TableName Where Text1 = 'ABC'" $adoRs.Open($sSQL, $Conn) If $adoRs.State = 1 Then With $adoRs if .Fields("ID").Value > 0 Then MsgBox(0, "Return 1", .Fields("Text1").Value) MsgBox(0, "Return 2", .Fields("Text2").Value) Else MsgBox(0, "", "Did not retrieve any data") EndIf EndWith Else MsgBox(0, "State Failed", "Connection State failed") EndIf $adoRs.Close $Conn.Close Edited July 30, 2015 by BigDaddyO
water Posted July 30, 2015 Posted July 30, 2015 Unfortunately the way how COM errors are handled has changed. You now need to add a COM error handler to your script and check for errors. 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
BigDaddyO Posted July 30, 2015 Author Posted July 30, 2015 grumble, grumble... ok, i'll add that.Thanks for the info
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