0

我正在使用 HP (Microfocus) Quality Center 12.5,并使用 Workflow 中的工具栏设计了一个按钮。

以下代码从 RecordSet 中提取第一个值,但不是所有值。如何从 RecordSet 中提取所有值并显示它?

Sub searchDefects()

  On Error Resume Next

    Dim a
     a = InputBox("Enter search query")

set TD1 = TDConnection
set com1 = TD1.command

com1.CommandText = "Select BG_BUG_ID FROM BUG WHERE BG_DESCRIPTION LIKE '%" 
&a &"%'"

set rec1 = com1.Execute

Dim i
DIM msg
msg = ""

rec1.First

 For i = 0 to rec1.RecordCount

     msg = msg & "," & rec1.FieldValue(i) & ","
     rec1.Next()

 Next

MsgBox msg

  On Error GoTo 0


End Sub
4

1 回答 1

0

经过反复试验,我找到了解决方案,但仍然不知道根本原因背后的原因以及它是如何解决的。任何反馈表示赞赏。

Sub SearchDefectsDescription()
On Error Resume Next

Dim a
a = InputBox("Enter search query for Description field")

set TD1 = TDConnection
set com1 = TD1.command

com1.CommandText = "Select BG_BUG_ID FROM BUG WHERE BG_DESCRIPTION LIKE '%" &a &"%'"
set rec1 = com1.Execute

Dim i
DIM msg
msg = "Bug ID" & vbnewline
rec1.First

If a = vbCancel Then
MsgBox "Search is cancelled"
Exit Sub

ElseIf Len(a) = 0 Then
MsgBox "Search input is empty, plesea try again."
Exit Sub

Else
For i = 0 to rec1.RecordCount

msg = msg & rec1.FieldValue(0) & rec1.FieldValue(1) & " "
rec1.Next()
Next
End If

MsgBox msg

On Error GoTo 0
End Sub
于 2017-11-02T23:02:59.490 回答