我有一个使用 ADODB 执行存储过程并将结果作为记录集读取的方法。一切正常,直到我将输出字段之一从 varchar(2000) 更改为 varchar(max) (SQL2008)。现在我无法从该字段中读取数据。奇怪的是,数据在运行Execute后立即在调试器中可见,但单步进入调试器会使数据消失。
这是代码:
Public Function sproc_RptEAComment(ByVal accountName As String, ByVal contractName As String,
ByVal acctType As String, ByVal asOfDate As DateTime,
ByVal sessionID As String, ByVal clin As String,
ByVal dollarDisplay As String) As List(Of sproc_RptEAComment_Row) Implements ISprocRepository.sproc_RptEAComment
Try
Dim cmd = New Command()
cmd.ActiveConnection = Connection
cmd.CommandType = CommandTypeEnum.adCmdStoredProc
cmd.CommandText = "sproc_RptEAComment"
ADOUtilities.AddParamToSproc(cmd, "@ChargeNum", accountName)
ADOUtilities.AddParamToSproc(cmd, "@Contract", contractName)
ADOUtilities.AddParamToSproc(cmd, "@EmployeeName", "")
ADOUtilities.AddParamToSproc(cmd, "@Org", acctType)
ADOUtilities.AddParamToSproc(cmd, "@HoursVal", "TRUE")
ADOUtilities.AddParamToSproc(cmd, "@Sort", "1")
ADOUtilities.AddParamToSproc(cmd, "@Employer", "")
ADOUtilities.AddParamToSproc(cmd, "@Type", "1")
ADOUtilities.AddParamToSproc(cmd, "@FromD", asOfDate.ToShortDateString())
ADOUtilities.AddParamToSproc(cmd, "@ToD", asOfDate.AddMonths(-5).ToShortDateString())
ADOUtilities.AddParamToSproc(cmd, "@SessionID", sessionID)
ADOUtilities.AddParamToSproc(cmd, "@Clin", clin)
ADOUtilities.AddParamToSproc(cmd, "@RptDisplay", "")
ADOUtilities.AddParamToSproc(cmd, "@Parm_DT", dollarDisplay)
Dim lst = New List(Of sproc_RptEAComment_Row)
Dim rs = cmd.Execute()
While Not (rs.EOF)
Dim newEntity = New sproc_RptEAComment_Row(rs)
lst.Add(newEntity)
rs.MoveNext()
End While
Return lst
Catch ex As Exception
MsgLogger.Err(ex)
Return Nothing
End Try
End Function
如果我在执行后立即查看调试器,我会看到这一点。请注意 EacJustCom 字段具有正确的字符串值:
我在调试器中迈出了一步,看到了这一点。价值消失了。请注意,“_Account”字段仍然完好无损(它被定义为 varchar(100)):