AutoIt操作Access数据库
安装Access数据库驱动 AccessDatabaseEngine.exe
-
这是为简化ADO操作封装的一些数据库操作接口
连接数据库
1
2
3
4
5
6
7Local $driver = 'Microsoft Access Driver (*.mdb)'
Local $dbname = @ScriptDir & '/xxx.mdb'
Local $dbuser = ''
Local $dbpassword = 'xxx'
Local $sConnectionString = 'DRIVER=' & $driver & ';Dbq=' & $dbname & ';Uid=' & $dbuser & ';PWD=' & $dbpassword & ';'
Local $oConnection = _ADO_Connection_Create()
_ADO_Connection_OpenConString($oConnection, $sConnectionString)若是Microsoft Access 2007及以后的版本,driver要写成 ‘Microsoft Access Driver (*.mdb *.accdb)’
查询数据
1
2
3$aQresult = _ADO_Execute($oConnection, "SELECT * FROM 表名", True)
$Qresult = _ArrayToString($aQresult[2])
ConsoleWrite("2 $Qresult " & $Qresult & @CRLF)关闭数据库连接
1
2_ADO_Connection_Close($oConnection)
$oConnection = null