我试图找到包含特定参考号的每条记录,然后为每条记录将其分配给一个会话,以便可以将其添加到 PDF 中。当我运行下面的代码时,它只执行 1 个参考号,即使可能有 3 条记录我需要从中获取数据。知道为什么它不为每条记录执行它吗?TIA
cmd = New SqlCommand
cmd.Connection = Con
cmd.CommandText = "SELECT [Physician First Name], [Physician Last Name], [Recipient Primary Business Street Address Line 1], [Recipient City], [Recipient State], [Recipient Zip Code] FROM tblData WHERE ReferenceNumber = @ReferenceNumber"
cmd.Parameters.Add(New SqlParameter("@ReferenceNumber", (ReferenceTextBox.Text)))
Dim reader As SqlDataReader = cmd.ExecuteReader()
For Each NPIlookup In reader
If (reader.Read()) Then
Session("DoctorFirstName") = reader(0)
End If
Session("PDF") &= Session("DoctorFirstName")
Next