本帖最后由 kodin 于 2012-5-10 23:36 编辑 #AutoIt3Wrapper_UseX64 = n
$adSource = @ScriptDir & "\DB1.mdb"
$adTable = "Table1"
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $adSource)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select * From " & $adTable & " WHERE wup='饼干'")
$DATA = ''
While Not $RS.eof And Not $RS.bof
If @error = 1 Then ExitLoop
$DATA+= $RS.Fields(2).value
$RS.movenext
WEnd
MsgBox(0,0,$DATA)
$RS.close
$addfld.Close
或者可以用这个方法直接查询。$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & $adSource)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("SELECT SUM(jiage) AS OrderTotal FROM " & $adTable & " WHERE wup='饼干'")
MsgBox(0,0,$RS.Fields(0).value)
$RS.close
$addfld.Close
|