我正在尝试提取以下查询的结果,但是当它到达 XML 字符串 [Processed Data] 时,它无法在 Excel 中显示结果。请问有人可以帮忙吗?谢谢
Public Sub Load_Error()
Dim ADOC As New ADODB.Connection
Dim SQL1 As String
Dim rst1 As New ADODB.Recordset
Dim i As Integer
Dim r As Integer
'#### Server Information
Server_Name = "A"
Database_Name = "B"
'#### Server Connection is opened
Worksheets("Load Errors").Activate
r = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
Range(Cells(1, 1), Cells(r, 6)).ClearContents
ADOC.Open "Provider=MSDASQL.1;DRIVER=SQL Server;SERVER=" & Server_Name & ";DATABASE=" & Database_Name & ";Trusted_Connection=Yes"
SQL1 = "SELECT [CreatedDate],[RecordStatus],[Comment], CONVERT(varchar(max),[ProcessedData]) as [Error Message], [DataExceptionID], [SessionID] " & _
" FROM [C].[dbo].[D](nolock) " & _
" where CreatedDate >= DATEADD(dd, 0, DATEDIFF(dd, 0, GETDATE())) and comment not in ('FrontierPositionRecon Load Errors','Errors', 'MCAP load errors') " & _
" order by createddate asc "
ADOC.CommandTimeout = 600
Set rst1 = ADOC.Execute(SQL1)
ActiveSheet.Cells(2, 1).CopyFromRecordset rst1
For i = 0 To rst1.Fields.Count - 1
ActiveSheet.Cells(1, i + 1).Value = rst1.Fields(i).Name
Next
Set rst1 = Nothing
Set ADOC = Nothing
End Sub