我有一个回复我的sp: Select 10 as Visits,5 as [Test_Drives],3 as Orders,'£5000' as [Profit_£],4 as Deliveries,'£6000' as [Delivered_Profit_£]FOR XML PATH('CONTENT'),ROOT('SOMEROOT') 但是当我使用ouptut时 Dim dr As New Sql
Select 10 as Visits,5 as [Test_Drives],3 as Orders,'£5000' as [Profit_£],4 as Deliveries,'£6000' as [Delivered_Profit_£] FOR XML PATH('CONTENT'),ROOT('SOMEROOT')
但是当我使用ouptut时
Dim dr As New SqlDataAdapter(SqlCmd) Dim tbl As New DataTable dr.Fill(tbl)
我收到一个错误
Column name ‘Profit_£’ contains an invalid XML identifier as required by FOR XML; ‘£'(0x00A3) is the first character at fault.
问题是我需要一个原始名称列.
我怎么能解决这个问题呢?
它的 not legal有一个包含£符号的节点名称,所以即使你能说服mssql允许你,你所做的任何事情都可能会被拒绝.如果你想要XML并且不关心它的结构是否很糟糕,你必须将常规结果集返回到.net应用程序并手动构建一个xml字符串.
最好不要先使用£; …作为[Profit_Pounds].
根据你的需要,FOR XML RAW会自动将£转换为_x ???名称.