cramaboule Posted May 8, 2013 Posted May 8, 2013 Hello I need to open with autoit a MS access database! This database is opening with this shortcut: "C:\Program Files (x86)\Microsoft Office\OFFICE11\MSACCESS.EXE" /wrkgrp \\server\folder\sys.mdw \\server\folder\database.mdb /user MyUser /pwd MyPass How do I open this in Autoit. (using COM object) $adoCon = ObjCreate("ADODB.Connection") $adoCon.Open("Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & $dbname&"; SystemDB="&$wkname&"; " , $user, $pwd) If Not(IsObj($adoCon)) Then MsgBox(0,"error","error") Exit EndIf ; create recordset $adoRs = ObjCreate("ADODB.Recordset") $adoRs.CursorType = 1 $adoRs.LockType = 3 $sQuery = 'SELECT * FROM Address;' ; open query $adoRs.Open($sQuery, $adoCon) ... I got an error with the Query ! Need help Thanks in advance ! Cramaboule My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website
Danp2 Posted May 8, 2013 Posted May 8, 2013 Have you tried like this?$adoCon.Open("Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & $dbname&"; SystemDB="&$wkname&";UID=" & $user & ";PWD=" & $pwd) Latest Webdriver UDF Release Webdriver Wiki FAQs
cramaboule Posted May 8, 2013 Author Posted May 8, 2013 Have you tried like this?$adoCon.Open("Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & $dbname&"; SystemDB="&$wkname&";UID=" & $user & ";PWD=" & $pwd) thanks but it doesn't work: C:\Users\Admin\Dropbox\au3\PO\test-accecss.au3 (33) : ==> The requested action with this object has failed.: My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website
Danp2 Posted May 8, 2013 Posted May 8, 2013 On which line did the error occur? The $adoCon.Open statement? Also, you mentioned earlier that you received an error when you attempted to run the sql statement, but you didn't indicate what the actual error message was. FWIW, I suspect the your initial attempt to open the file is failing and I don't believe your error checking will work as written. Here's some code from a script I previously wrote:$sqlCon = ObjCreate("ADODB.Connection") $sqlCon.Mode = 16 ; sharedenynone $sqlCon.CursorLocation = 3 ; client side cursor ; Retrieve active call from ACD database $sqlString = "DRIVER=Microsoft Access Driver (*.mdb);UID=userid;PWD=password;UserCommitSync=Yes;Threads=3;PageTimeout=5;MaxScanRows=8;MaxBufferSize=2048;FIL=MS Access;DriverId=25;DefaultDir=\\Server\Reports;DBQ=\\Server\Reports\dbACD.mdb" $sqlCon.Open ($sqlString) If $IEComErrorNumber = 0 Then $sqlRs = ObjCreate("ADODB.Recordset") $sqlString = "select count(*) as cnt from status where agentext <> 0 and status <> " & $AgentLogin $sqlRs.open ($sqlString, $sqlCon) If Not $sqlRs.EOF Then ; Record / field level functionality goes here Endif $sqlRs.close Endif If $sqlCon.state = $adStateOpen Then $sqlCon.close EndIf _IEErrorHandlerDeRegister() Essentially, this uses the COM error handler from IE.AU3, which avoids the script from erroring out when a COM error occurs. If you are using the latest beta version, then this won't be necessary. Latest Webdriver UDF Release Webdriver Wiki FAQs
cramaboule Posted May 13, 2013 Author Posted May 13, 2013 Well,.... For some reasons it is working on the Access Server but not remotely...( from my remote PC !) Both works fine for me! $adoCon.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $dbname & ";Jet OLEDB:System Database="&$wkname&";User ID="&$user&";Password="&$pwd&";") $adoCon.Open("Driver={Microsoft Access Driver (*.mdb)};DBQ=" & $dbname&";SystemDB="&$wkname&";Uid="&$user&";Pwd="&$pwd&";") My Autoit programs: MAC Address - - Delete Temp Files - - Ping Test - - Play Video with VLC full screen dual monitors - - Set IP - - Pics Converter - - AutoUpdater - - CPU Usage - - Ending Script Nicely - - GDI+ GUI crossfades (slide transitions) - - Beamer - - Search and Search in Files - - Silent Ninite Others: Export Icons into Dll - - My website
Danp2 Posted May 13, 2013 Posted May 13, 2013 Sounds like a rights issue to me. Can't help any further because you didn't post any other useful details. Latest Webdriver UDF Release Webdriver Wiki FAQs
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