ACCESS问题求助。【已解决】
本帖最后由 basc 于 2013-5-6 15:47 编辑已知1.mdb文件,密码为123456
表名userinfo
字段id_num
id_key
id_name
id_sex
id_cardkind
需要读取最后一行的id_num id_keyid_name 内容,用MSGBOX来表示,求解决。 回复 1# basc
Local $mdb_data_path = @ScriptDir & "\1.mdb", $mdb_data_pwd = "123456"
Local $tblname = "userinfo"
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select id_num,id_key,id_name From " & $tblname & " " )
While Not $RS.eof And Not $RS.bof
If @error = 1 Then ExitLoop
$RS.movenext
WEnd
MsgBox(0, 0, "id_num = " & $RS.Fields(0).value & @CRLF _
& "id_key = " & $RS.Fields(1).value & @CRLF _
& "id_name = " & $RS.Fields(2).value)
$RS.close
$addfld.Close 回复 2# xms77
+> ============================================
>运行 AU3Check (1.54.21.0)开始目录:D:\autoit3
+>21:47:51 AU3Check 完成:0
>运行:(3.3.7.15):D:\autoit3\autoit3.exe "F:\rs\a\autoit3\basc\access.au3"
F:\rs\a\autoit3\basc\access.au3 (12) : ==> ??????(?????).:
MsgBox(0, 0, "id_num = " & $RS.Fields(0).value & @CRLF & "id_key = " & $RS.Fields(1).value & @CRLF & "id_name = " & $RS.Fields(2).value)
MsgBox(0, 0, "id_num = " & $RS.Fields(0).value ^ ERROR
->21:47:52 AutoIT3.exe 完成::1
+>21:47:53 ACNWrapper 完成..
>退出代码: 1 运行时间: 1.704 秒
不行啊 回复 3# basc
不好意思,代码没有跑过,再试试这样呢
Local $mdb_data_path = @ScriptDir & "\1.mdb", $mdb_data_pwd = "123456"
Local $tblname = "userinfo"
Local $lastNum, $lastkey,$lastName
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select last(id_num) as lastnum From " & $tblname & " " )
$lastNum = $RS.fields("lastnum").value
$RS.close
$RS.Open("Select last(id_key) as lastKey From " & $tblname & " " )
$lastkey = $RS.fields("lastKey").value
$RS.close
$RS.Open("Select last(id_Name) as lastname From " & $tblname & " " )
$lastName = $RS.fields("lastName").value
$RS.close
$addfld.Close
MsgBox(0, 0, "id_num = " & $lastNum & @CRLF _
& "id_key = " & $lastkey & @CRLF _
& "id_name = " & $lastName) 回复 4# xms77
可以了,有空能否给个注释啊,我好学学
页:
[1]