找回密码
 加入
搜索
查看: 1833|回复: 4

[系统综合] ACCESS问题求助。【已解决】

[复制链接]
发表于 2013-5-5 19:19:53 | 显示全部楼层 |阅读模式
本帖最后由 basc 于 2013-5-6 15:47 编辑

已知1.mdb文件,密码为123456
表名userinfo
字段id_num
id_key
id_name
id_sex
id_cardkind

需要读取最后一行的id_num id_key  id_name 内容,用MSGBOX来表示,求解决。
发表于 2013-5-5 21:32:53 | 显示全部楼层
回复 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
 楼主| 发表于 2013-5-5 21:48:04 | 显示全部楼层
回复 2# xms77


    +> ============================================
>运行 AU3Check (1.54.21.0)  开始目录:D:\autoit3
+>21:47:51 AU3Check 完成[CODE]: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 完成:[CODE]:1
+>21:47:53 ACNWrapper 完成..
>退出代码: 1        运行时间: 1.704 秒
不行啊
发表于 2013-5-6 13:03:43 | 显示全部楼层
回复 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)
 楼主| 发表于 2013-5-6 15:46:19 | 显示全部楼层
回复 4# xms77
可以了,有空能否给个注释啊,我好学学
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-17 21:18 , Processed in 1.647062 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表