在sql查询中使用双引号c#

时间:2015-03-31 15:57:14

标签: c# sql-server string

我正在开发一个在Sqlserver数据库中执行查询的应用程序。其中一个查询需要双引号。

select ....soapenv="http://schemas.xmlsoap.org/soap/envelope/"...from...where...

我将查询放在字符串类型变量中。我使用倒条来scape双引号并在字符串中定义它们。 但是当我执行我的应用程序时,我的应用程序执行此查询时出现错误。

这是错误消息:

Incorrect syntax near the keyword 'declare'.

'soapenv' is not a recognized CURSOR option. 

如何定义我的查询?

这是我的疑问:

SELECT XMLFile.value('declare namespace   soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\";declare namespace cus=\"http://nestle-eai/Schemas/esb/Customer\";declare namespace inf=\"http://nestle-eai/Schemas/esb/Infrastructure\";declare namespace ars=\"http://nestle-eai/Schemas/ar/arService\";(soapenv:Envelope/soapenv:Body/ars:setCustomerIn/parameters/cus:customer/cus:VeevaId)[1]','VARCHAR(20)') FROM dbo.VEEVA_XML

提前致谢! 此致

1 个答案:

答案 0 :(得分:0)

sql查询应该是这样的(看看[“]):

SELECT XMLFile.value('declare namespace soapenv="http://schemas..."; ... ','VARCHAR(20)') FROM ...

在c#中,与java中的相同:

String qry = "SELECT XMLFile.value('declare namespace soapenv=\"http://schemas...\"; ... ','VARCHAR(20)') FROM ...";

这里[\“]编码[”]。