执行阅读器

时间:2016-07-20 16:03:04

标签: sql sql-server vb.net

我有一个在我们的服务器上运行的应用程序,它作为我们所有内部应用程序的“服务”。此应用程序每25分钟抛出一次错误。错误是:“超时已到期。在操作完成之前已经过了超时时间,或者服务器没有响应。” “为了评估索引属性,必须限定属性,并且必须由用户显式提供参数。”直到我们对我们的应用程序进行了一些最近的更改,才发生这种情况失败的代码只是调用存储过程并使用sqldatareader执行它。存储过程如下:

ALTER PROCEDURE GetActivePatientCoreMeasures 
-- Add the parameters for the stored procedure here

AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

SELECT DISTINCT ADT.[PV1 Room], adt.[Patient Account Number], [Diagnosis Codes].Description
FROM [CPSISQL].dbo.ADT
LEFT JOIN [CPSISQL].dbo.ADT_Diagnosis 
ON [CPSISQL].dbo.ADT.[Patient Account Number] = [CPSISQL].dbo.ADT_Diagnosis.[Patient Account #]
RIGHT JOIN [Diagnosis Codes]
ON ADT_Diagnosis.[Diagnosis Code] = [Diagnosis Codes].Code
WHERE [CPSISQL].dbo.ADT.[PV1 Discharge Date/Time] = ''
AND
(
    [CPSISQL].dbo.ADT.[PV1 Department] = '028' OR
    [CPSISQL].dbo.ADT.[PV1 Department] = '030' OR
    [CPSISQL].dbo.ADT.[PV1 Department] = '032' OR
    [CPSISQL].dbo.ADT.[PV1 Department] = '038' OR
    [CPSISQL].dbo.ADT.[PV1 Department] = '042' 
)
AND NOT(ADT_Diagnosis.[Diagnosis Type] = 'A')
ORDER BY adt.[PV1 Room]
END

以下是调用存储过程的例程:

Private Sub UpdateDataFromADT_Codes(SqlConn As SqlConnection)
        Dim sqlCMD As SqlCommand = New SqlCommand("EXEC GetActivePatientCoreMeasures", SqlConn)
        Dim readerSQL As SqlDataReader = sqlCMD.ExecuteReader()

        While readerSQL.Read
            Dim thePatientNumber As String = SqlToString(readerSQL(1))
            Dim theCoreMeasure As String = SqlToString(readerSQL(2))

            For i As Integer = 0 To QueueOfPatientData.Count - 1
                If QueueOfPatientData(i).PatientNumber = thePatientNumber Then
                    With QueueOfPatientData(i)
                        Select Case theCoreMeasure
                            Case "PN"
                                .PN = "Yes"
                            Case "Sepsis"
                                .Sepsis = "Yes"
                            Case "STROKE"
                                .Stroke = "Yes"
                            Case "VTE"
                                .VTE = "Yes"
                            Case "CHF"
                                .CHF = "Yes"
                            Case "AMI"
                                .AMI = "Yes"
                        End Select
                    End With
                    'exit for since patient was found
                    Exit For
                End If
            Next
        End While

        readerSQL.Close()
    End Sub

任何帮助将不胜感激!

0 个答案:

没有答案