spudw2k Posted May 18, 2020 Posted May 18, 2020 (edited) Just to clarify. Are you looking to automate the Access application, or access the query stored in the ACCDB and return the results of the query to AutoIt (in the form of an array or something)? If the latter, see if you can do this: _Get_Records("SELECT * FROM QueryName") I tested it with my UDF after tweaking some code, but that worked for me. Edited May 18, 2020 by spudw2k Reveal hidden contents Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
gmmg Posted May 17 Posted May 17 Hi @kcvinu, I am using the Access UDF and want to open a password protected “accdb” database. I can't do that with the standard UDF. My solution is, i adjusted the connection string in the function or is there a better solution? $Connection_String = "Provider=Microsoft.ACE.OLEDB.12.0;Data source=" & $DBPath & ";Jet OLEDB:Database Password=" & $PassWord That still needs to be done nicely in the code or how can I integrate this into the UDF? #Region - Function _Start_Connection ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Start_Connection ; Description ...: This function will start or open a new connection. ; Syntax ........: _Start_Connection($DBPath [, $UserName = ""[, $PassWord = ""]]) ; Parameters ....: $DBPath - Path of your Access database file.(with *.accdb extension and a ";" sign at the end") ; $UserName - [optional] Username of your database . Default is "". ; $PassWord - [optional] Password of your database. Default is "". ; Return values .: String. If connection is opneed then, it will be "OK". And if it is failed then, "Failed " & @error ; Author ........: spudw2k. I've made a little change to this function ; Modified ......: 2015 sep ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: _Start_Connection(@ScriptDir & "\TestDB.accdb;") ; =============================================================================================================================== Func _Start_Connection($DBPath, $UserName = "", $PassWord = "") If Not IsObj($objConnection) Then Return -1 $Connection_String = $sDataProvider & $DBPath & ";" If $UserName Then $Connection_String &= "User ID=" & $UserName & ";" If $PassWord Then $Connection_String &= "Password=" & $PassWord & ";" ; this connection string works with my pwd protected DB $Connection_String = "Provider=Microsoft.ACE.OLEDB.12.0;Data source=" & $DBPath & ";Jet OLEDB:Database Password=" & $PassWord $objConnection.Open($Connection_String) If @error Then $ConnStatus = "Failed " & @error Return $ConnStatus EndFunc KR, Marcel
gmmg Posted May 17 Posted May 17 I have changed the code in the Func _Start_Connection Function from: If $PassWord Then $Connection_String &= "Password=" & $PassWord & ";" to If $PassWord Then $Connection_String &= ";Jet OLEDB:Database Password=" & $PassWord & ";" #Region - Function _Start_Connection ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Start_Connection ; Description ...: This function will start or open a new connection. ; Syntax ........: _Start_Connection($DBPath [, $UserName = ""[, $PassWord = ""]]) ; Parameters ....: $DBPath - Path of your Access database file.(with *.accdb extension and a ";" sign at the end") ; $UserName - [optional] Username of your database . Default is "". ; $PassWord - [optional] Password of your database. Default is "". ; Return values .: String. If connection is opneed then, it will be "OK". And if it is failed then, "Failed " & @error ; Author ........: spudw2k. I've made a little change to this function ; Modified ......: 2015 sep ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: _Start_Connection(@ScriptDir & "\TestDB.accdb;") ; =============================================================================================================================== Func _Start_Connection($DBPath, $UserName = "", $PassWord = "") If Not IsObj($objConnection) Then Return -1 $Connection_String = $sDataProvider & $DBPath & ";" If $UserName Then $Connection_String &= "User ID=" & $UserName & ";" ;If $PassWord Then $Connection_String &= "Password=" & $PassWord & ";" If $PassWord Then $Connection_String &= ";Jet OLEDB:Database Password=" & $PassWord & ";" ;$Connection_String = "Provider=Microsoft.ACE.OLEDB.12.0;Data source=" & $DBPath & ";Jet OLEDB:Database Password=123456789" ;$Connection_String = "Provider=Microsoft.ACE.OLEDB.12.0;Data source=" & $DBPath & ";Jet OLEDB:Database Password=" & $PassWord & ";" $objConnection.Open($Connection_String) If @error Then $ConnStatus = "Failed " & @error Return $ConnStatus EndFunc #EndRegion KR, Marcel
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