I’m trying to find out if there is an AutoIt capability to connect to a MS Access database and particularly with Access 2007 and an .accdb file. I’ve tried the following which I found the core from a forum but I couldn’t get it to work. So I’m just posting this problem now and will post a solution once I find it myself. If you know the solution then please post your reply here. The forum stated the code was working with MS Access 2000 but there is probably not too many people with that version nowadays.
$dbname = "C:\Users\vk\Documents\db\Marketing\articleSubmissionsTutorialRef.mdb"
$tblname = "articles"
$fldname = "UserName"
$query = "SELECT * FROM " & $tblname & " WHERE articleID = '4'"
Dim $_output
$adoCon = ObjCreate("ADODB.Connection")
$adoCon.Open("Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & $dbname)
;$adoCon.Open("Driver={Microsoft Access Driver (*.accdb)}; DBQ=" & $dbname)
$adoRs = $adoCon.Execute($query)
While Not $adoRs.EOF
$_output = $_output & $adoRs.fields("title").value & @CRLF
$adoRs.MoveNext
WEnd
$adoCon.Close
MsgBox(0,"Guest List",$_output)
These are the errors I receive:
>Running:(3.3.0.0):C:\Program Files\AutoIt3\autoit3.exe "C:\Program Files\AutoIt3\SciTE\test_access.au3"
### COM Error ! Number: 80020009 ScriptLine: 46 Description:[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
### COM Error ! Number: 000000A9 ScriptLine: 47 Description:[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
C:\Program Files\AutoIt3\SciTE\test_access.au3 (48) : ==> Object referenced outside a "With" statement.:
$_output = $_output & $adoRs.fields("title").value & @CRLF
$_output = $_output & $adoRs.fields("title")^ ERROR
->03:03:46 AutoIT3.exe ended.rc:1
+>03:03:47 AutoIt3Wrapper Finished
I tried the above with both accdb and mdb files. Will update the answer on another post.
















































