找回密码
 加入
搜索
查看: 2795|回复: 5

[系统综合] MDB多条件查询 应该怎么写?【已解决】

  [复制链接]
发表于 2012-5-19 12:13:01 | 显示全部楼层 |阅读模式
本帖最后由 病毒专收员 于 2012-5-19 16:22 编辑
Func _accessQuery_Like($adSource, $adTable, $adCol1,$Find1, $adCol2,$Find2, $adFull = 1)
        Local $I, $Rtn
        Local $oADO = 'ADODB.Connection'
        If IsObj($oADO) Then
                $oADO = ObjGet('', $oADO)
        Else
                $oADO = _dbOpen($adSource)
        EndIf
        If IsObj($oADO) = 0 Then Return SetError(1)
        Local $oRec = _dbOpenRecordset();ObjCreate("ADODB.Recordset")
        If IsObj($oRec) = 0 Then Return SetError(2)
        $oRec.Open("SELECT * FROM " &$adTable & " WHERE " & $adCol1 & " = '" & $Find1 & "'" & " AND " & $adCol2 & " = '" & $Find2 & "'", $oADO, $adOpenStatic, $adLockOptimistic)
        If $oRec.RecordCount < 1 Then
                Return SetError(1)
        Else
                SetError(0)
                $oRec.MoveFirst()
                ;;MsgBox(0,'TEST', "Number of records: " & $oRec.RecordCount);;<<======  For testing only
                Do
                        If $adFull = 1 Then
                                For $I = 0 To _accessCountFields($adSource, $adTable) - 1
                                        ;;MsgBox(0,'TEST 2 ', "Value of field " & $oRec.Fields($I).Name & ' is:' & @CRLF & @CRLF & $oRec.Fields($I).Value);;<<======  For testing only
                                        $Rtn = $Rtn & $oRec.Fields($I).Value & Chr(28);;<<====== Separate the fields with a non-printable character
                                Next
                        EndIf
                        $Rtn = $Rtn & Chr(29);;<<====== Separate the records with a non-printable character
                        $oRec.MoveNext()
                Until $oRec.EOF
                $oRec.Close
                $oADO.Close
                If $adFull = 1 Then Return StringSplit(StringTrimRight($Rtn, 2), Chr(29))
                Return StringSplit(StringTrimRight($Rtn, 1), Chr(29))
        EndIf
EndFunc   ;==>_accessQueryLike


自己解决了!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2012-5-19 12:26:46 | 显示全部楼层
曾经做过,用的正则。
 楼主| 发表于 2012-5-19 12:34:02 | 显示全部楼层
回复 2# 水木子


    =,- 记得有SQL的语句可以直接实现,但是忘记了。 网上淘了半天也没找到!
发表于 2012-5-19 12:45:17 | 显示全部楼层
论坛里有的。
搜索“数据库”即可。
给你一个连接吧。
http://www.autoitx.com/forum.php ... =%CA%FD%BE%DD%BF%E2
发表于 2012-5-19 12:57:13 | 显示全部楼层
楼上应该能行
 楼主| 发表于 2012-5-19 16:14:28 | 显示全部楼层
回复 4# chenronting


    谢谢,自己解决了!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-30 11:37 , Processed in 0.144175 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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