In a function I used KEDIT for windows to write a query in vb.net which returns a xml document and then that xml is displayed as Excel spreadsheet. The problem I have is that two column data is being split and then entered into the next column. How do I fix this?
Here is my function
Private Shared Function GetSql(ByVal adtmStartDateTime As Date, ByVal adtmEndDateTime As Date) As String
Dim strSQL As String
strSQL = "--DROP TABLE #TEMP_Request" + vbCrLf +
"" + vbCrLf +
";WITH XMLNAMESPACES ('http://www.w3.org/2003/05/soap-envelope' AS soap," + vbCrLf +
"'http://niem.gov/niem/niem-core/2.0' AS nc," + vbCrLf +
"'urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:CommonTypes-4.0' AS ecf," + vbCrLf +
"Default 'urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:DocumentQueryMessage-4.0')" + vbCrLf +
"SELECT MessageID, ProcessDateTime AS 'RequestDateTime'," + vbCrLf +
"Convert(Xml, InputMessage.Body).value('(//*[local-name()=""DocumentQueryMessage""]/nc:CaseTrackingID)[1]','varchar(250)') AS 'CaseNumber'" + vbCrLf +
"INTO #TEMP_Request" + vbCrLf +
"FROM InputMessage" + vbCrLf +
"WHERE" + vbCrLf +
"(QueueName = 'ECF_COURTRECORD_QUERY_02')" + vbCrLf +
"And (ProcessDateTime >= CONVERT(DATETIME, '" + adtmStartDateTime.ToString + "', 102))" + vbCrLf +
"AND (ProcessDateTime < CONVERT(DATETIME, '" + adtmEndDateTime.ToString + "', 102))" + vbCrLf +
"And" + vbCrLf +
"CONVERT(XML, InputMessage.Body).exist('(//*[local-name()=""DocumentQueryMessage""])') = 1" + vbCrLf +
";WITH XMLNAMESPACES ('http://www.w3.org/2003/05/soap-envelope' AS soap," + vbCrLf +
"'http://niem.gov/niem/niem-core/2.0' AS nc," + vbCrLf +
"'urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:CommonTypes-4.0' AS ecf," + vbCrLf +
"'http://niem.gov/niem/domains/jxdm/4.0' AS d," + vbCrLf +
"Default 'urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:DocumentResponseMessage-4.0')" + vbCrLf +
"SELECT " + vbCrLf +
"(SELECT OM.MessageID, TR.RequestDateTime, TR.CaseNumber," + vbCrLf +
"Convert(Xml, OM.Body).value('(//DocumentResponseMessage/ecf:Document/nc:DocumentDescriptionText)[1]','varchar(250)') AS 'DocumentName'," + vbCrLf +
"Convert(Xml, OM.Body).value('(//DocumentResponseMessage/ecf:Document/ecf:DocumentMetadata/d:RegisterActionDescriptionText)[1]','varchar(250)') AS 'CaseEventDescription'," + vbCrLf +
"Convert(Xml, OM.Body).value('(soap:Envelope/soap:Body/DocumentResponseMessage/ecf:Document/nc:DocumentFiledDate/nc:DateTime)[1]','datetime') AS 'DocumentFiledDate'" + vbCrLf +
"FROM #TEMP_Request AS TR" + vbCrLf +
"INNER JOIN OutputMessage AS OM ON (TR.MessageID = OM.MessageID)" + vbCrLf +
"WHERE" + vbCrLf +
"Convert(Xml, OM.Body).value('(soap:Envelope/soap:Body/DocumentResponseMessage/ecf:Document/nc:DocumentIdentification/nc:IdentificationID)[1]','varchar(250)') IS NOT NULL " + vbCrLf +
"For Xml PATH('DocumentGetAuditReport'), Type) " + vbCrLf +
"For Xml PATH('Results') "
Return strSQL
End Function
Here is result in xml, the part that has a problem in Excel.
<DocumentGetAuditReport xmlns="urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:DocumentResponseMessage-4.0" xmlns:d="http://niem.gov/niem/domains/jxdm/4.0" xmlns:ecf="urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:CommonTypes-4.0" xmlns:nc="http://niem.gov/niem/niem-core/2.0" xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<MessageID>422A</MessageID>
<RequestDateTime>2018-07-20T15:06:39.087</RequestDateTime>
<OrganizationORI>TP0070</OrganizationORI>
<OrganizationName>St Martin County Attorney</OrganizationName>
<CaseNumber>00-CV-00-001</CaseNumber>
<DocumentName>Findings, Conclusions & Orderfor Disbursal of Funds to petitioner (Comdemnation for Roadway Purposes</DocumentName>
<CaseEventDescription>Findings of Fact, Conclusions of Law and Order</CaseEventDescription>
<DocumentFiledDate>2017-02-28T15:46:39</DocumentFiledDate>
</DocumentGetAuditReport>
Here is the Excel result
"DocumentGet Integration Query Service Documents Requested and Provided July 2018"
Request DateTime Case Number Document Name Case Event Description Document Filed Date
2018-07-20T14:32:31.247 00-CV-00-001 Findings Conclusions & Orderfor Disbursal of Funds to petitioner (Comdemnation for Roadway Purposes Findings of Fact Conclusions of Law and Order 2/28/2017
Correct output should have
Document Name column with the following data
Findings, Conclusions & Orderfor Disbursal of Funds to petitioner (Comdemnation for Roadway Purposes
Currently this column on have Findings
Case Event Description column should have
Findings of Fact, Conclusions of Law and Order
Currently this column have Conclusions & Orderfor Disbursal of Funds to petitioner (Comdemnation for Roadway Purposes which is wrong
Document Filed Date column has Findings of Fact. This is wrong. It should have the 2/28/2017 date instead
How do I fix my KEDIT or what do I need to do so the data in each column is not cut off?
Thanks in advance.
What I have tried:
Private Shared Function GetSql(ByVal adtmStartDateTime As Date, ByVal adtmEndDateTime As Date) As String
Dim strSQL As String
strSQL = "--DROP TABLE #TEMP_Request" + vbCrLf +
"" + vbCrLf +
";WITH XMLNAMESPACES ('http://www.w3.org/2003/05/soap-envelope' AS soap," + vbCrLf +
"'http://niem.gov/niem/niem-core/2.0' AS nc," + vbCrLf +
"'urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:CommonTypes-4.0' AS ecf," + vbCrLf +
"Default 'urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:DocumentQueryMessage-4.0')" + vbCrLf +
"SELECT MessageID, ProcessDateTime AS 'RequestDateTime'," + vbCrLf +
"Convert(Xml, InputMessage.Body).value('(//*[local-name()=""DocumentQueryMessage""]/nc:CaseTrackingID)[1]','varchar(250)') AS 'CaseNumber'" + vbCrLf +
"INTO #TEMP_Request" + vbCrLf +
"FROM InputMessage" + vbCrLf +
"WHERE" + vbCrLf +
"(QueueName = 'ECF_COURTRECORD_QUERY_02')" + vbCrLf +
"And (ProcessDateTime >= CONVERT(DATETIME, '" + adtmStartDateTime.ToString + "', 102))" + vbCrLf +
"AND (ProcessDateTime < CONVERT(DATETIME, '" + adtmEndDateTime.ToString + "', 102))" + vbCrLf +
"And" + vbCrLf +
"CONVERT(XML, InputMessage.Body).exist('(//*[local-name()=""DocumentQueryMessage""])') = 1" + vbCrLf +
";WITH XMLNAMESPACES ('http://www.w3.org/2003/05/soap-envelope' AS soap," + vbCrLf +
"'http://niem.gov/niem/niem-core/2.0' AS nc," + vbCrLf +
"'urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:CommonTypes-4.0' AS ecf," + vbCrLf +
"'http://niem.gov/niem/domains/jxdm/4.0' AS d," + vbCrLf +
"Default 'urn:oasis:names:tc:legalxml-courtfiling:schema:xsd:DocumentResponseMessage-4.0')" + vbCrLf +
"SELECT " + vbCrLf +
"(SELECT OM.MessageID, TR.RequestDateTime, TR.CaseNumber," + vbCrLf +
"Convert(Xml, OM.Body).value('(//DocumentResponseMessage/ecf:Document/nc:DocumentDescriptionText)[1]','varchar(250)') AS 'DocumentName'," + vbCrLf +
"Convert(Xml, OM.Body).value('(//DocumentResponseMessage/ecf:Document/ecf:DocumentMetadata/d:RegisterActionDescriptionText)[1]','varchar(250)') AS 'CaseEventDescription'," + vbCrLf +
"Convert(Xml, OM.Body).value('(soap:Envelope/soap:Body/DocumentResponseMessage/ecf:Document/nc:DocumentFiledDate/nc:DateTime)[1]','datetime') AS 'DocumentFiledDate'" + vbCrLf +
"FROM #TEMP_Request AS TR" + vbCrLf +
"INNER JOIN OutputMessage AS OM ON (TR.MessageID = OM.MessageID)" + vbCrLf +
"WHERE" + vbCrLf +
"Convert(Xml, OM.Body).value('(soap:Envelope/soap:Body/DocumentResponseMessage/ecf:Document/nc:DocumentIdentification/nc:IdentificationID)[1]','varchar(250)') IS NOT NULL " + vbCrLf +
"For Xml PATH('DocumentGetAuditReport'), Type) " + vbCrLf +
"For Xml PATH('Results') "
Return strSQL
End Function