[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
使用 rs.RecordCount
  1. set cn=WScript.CreateObject("ADODB.Connection")
  2. set rs=WScript.CreateObject("adodb.recordset")
  3. cn.open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=\\win-pc\meno\vbs\ceshi.mdb"
  4. sql="select MacAddress From speed where macaddress = '7'"
  5. rs.CursorLocation = 3
  6. rs.open sql,Cn,1,3
  7. if rs.RecordCount > 0 Then
  8.     msgbox "有相同数据"
  9. else
  10.     msgbox "无此数据"
  11. end if
复制代码
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    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
  1. sql = "select MacAddress Form speed where MacAddress = '" & MacAddr &  "'"
复制代码
附:
VB/VBS语句中,字符串需要用一对英文"双"引号包含起来,例如:
  1. Msgbox " Hello World ! "
复制代码
SQL查询语句中,字符串需要用一对英文'单'引号包含起来,例如:
  1. select ' hello world! '
复制代码
『千江有水千江月』千江有水,月映千江;万里无云,万里青天。    http://yu2n.qiniudn.com/

TOP

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

评分人数

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

TOP

返回列表