1

Could you please help me , How to store multi line SQL query in app.config file.

below is Example:- I want to store this query in App.config file.

select * from users u LEFT join Employee E on u.id = E.id
Inner Join Department D on d.id=E.id
Left Join Orders O On O.Id = E.id
Inner Join Values V v.id = E.id 
WHERE
u.createTime>=Getdate()-1 AND u.deletstatus=1
AND D.Id<>0
Kumar
  • 65
  • 2
  • 9
  • 1
    Possible duplicate of [Is it possible to split a string across multiple lines in an XML file? If so, how?](http://stackoverflow.com/questions/1184097/is-it-possible-to-split-a-string-across-multiple-lines-in-an-xml-file-if-so-ho) – dotnetom Jul 06 '16 at 05:31
  • please refer this url http://stackoverflow.com/questions/10652751/multi-line-text-in-a-web-config-file – Sanjay Radadiya Jul 06 '16 at 05:35
  • No sir, that didn't fix my issue – Kumar Jul 06 '16 at 11:11

1 Answers1

2

As others pointed out, you can have a multi-line string in XML. Maybe you didn't escape the XML special chracters:

Ampersand       &amp;   &
Less-than       &lt;    <
Greater-than    &gt;    >
Quotes          &quot;  "
Apostrophe      &apos;  '

Here is the XML for your App.config

<appSettings>
  <add key="SqlQuery" 
       value="select * from users u LEFT join Employee E on u.id = E.id
              Inner Join Department D on d.id=E.id
              Left Join Orders O On O.Id = E.id
              Inner Join Values V v.id = E.id 
              WHERE
              u.createTime&gt;=Getdate()-1 AND u.deletstatus=1
              AND D.Id&lt;&gt;0" />
</appSettings>
amr ras
  • 136
  • 10