返回列表 发帖
使用 rs.RecordCount
set cn=WScript.CreateObject("ADODB.Connection")
set rs=WScript.CreateObject("adodb.recordset")
cn.open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=\\win-pc\meno\vbs\ceshi.mdb"
sql="select MacAddress From speed where macaddress = '7'"
rs.CursorLocation = 3
rs.open sql,Cn,1,3
if rs.RecordCount > 0 Then
    msgbox "有相同数据"
else
    msgbox "无此数据"
end ifCOPY
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

回复 7# 437153


我这里没有这个问题。
(测试环境:win8.1 x64 + office2007)

参考:Win7 上不能用 microsoft.jet.oledb.4.0
http://www.vbgood.com/thread-102510-1-1.html
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

回复 10# 437153
sql = "select MacAddress Form speed where MacAddress = '" & MacAddr &  "'"COPY
附:
VB/VBS语句中,字符串需要用一对英文"双"引号包含起来,例如:
Msgbox " Hello World ! "COPY
SQL查询语句中,字符串需要用一对英文'单'引号包含起来,例如:
select ' hello world! 'COPY
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

回复 12# 437153
如果你想要Msgbox弹出如下内容的提示框:
" select MacAddress From speed where macaddress = 'mac=14:CF:92:1B:1D:52' "COPY
你可以这么写Msgbox语句(注意英文双引号的写法有3种):
str01 = """ select MacAddress From speed where macaddress = 'mac=14:CF:92:1B:1D:52' """
str02 = """" & " select MacAddress From speed where macaddress = 'mac=14:CF:92:1B:1D:52' " & """"
str03 = Chr(34) & " select MacAddress From speed where macaddress = 'mac=14:CF:92:1B:1D:52' " & Chr(34)
Msgbox str01
Msgbox str02
Msgbox str03COPY
结果都是同样的。
1

评分人数

『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

返回列表