我正在尝试从 vbs 查询 SQL 数据库,但是当没有找到记录时出现错误
ADODB.Field : BOF 或 EOF 为 True,或者当前记录已被删除。请求的操作需要当前记录。
我想我需要使用 IF NOT 语句来捕获是否找不到记录,但我不知道它需要去哪里。
Do Until objFile.AtEndofStream
strAppName = objFile.ReadLine
ConnString="DRIVER={SQL Server};SERVER=aardvark002;UID=***;PWD=***;DATABASE=DEW_Users"
SQL = "USE Win7AppData SELECT " & Chr(34) & strCountry & Chr(34) & " FROM AppsByCountry WHERE Application = '" & strAppName & "'"
Set Connection = CreateObject("ADODB.Connection")
Set Recordset = CreateObject("ADODB.Recordset")
Connection.Open ConnString
Recordset.Open SQL,Connection
strApproval = Recordset(strCountry)
If StrApproval = "YES" Then
strApproval = "Approved"
Else
strApproval = "Denied"
End If
objExcel.Cells(intRow, 1).Value = strAppname
objExcel.Cells(intRow, 2).Value = strCountry
objExcel.Cells(intRow, 3).Value = strApproval
intRow = intRow + 1
Loop