how to add double quotation to string using C#

Posted by Lokeshbasana under C# on 7/1/2009 | Views : 16307 | Status : [Member] | Replies : 3
string query = "select OrderCode,OrderDesc,to_date(OrderDate,'dd-MON-YYYY') As "OrderDate" from tblOrder";

//getting Error to the above string how to add double quotation to my OrderDate string

while debuging the string must look like

select OrderCode,OrderDesc,to_date(OrderDate,'dd-MON-YYYY') As "OrderDate" from tblOrder

thanks




Responses

Posted by: Raja on: 7/1/2009 [Member] Starter

Up
0
Down
use \ (backslash) escape character to do that.

For example, your string should look like

string query = "select OrderCode,OrderDesc,to_date(OrderDate,'dd-MON-YYYY') As \"OrderDate\" from tblOrder"; 



Thanks

Regards,
Raja, USA

Lokeshbasana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 7/1/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Evening Lokeshbasana

Change it this way

string query = "select OrderCode,OrderDesc,to_date(OrderDate,'dd-MON-YYYY') as [ OrderDate]  from tblOrder";




as you can see above i have used Brackets. that is how you should do it in SQL.

Thank you for Posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Lokeshbasana, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raja on: 7/2/2009 [Member] Starter

Up
0
Down
Vuyiswamb,

I think his question is not how the query should look like but he wants " (double quote) to appear in the string so I guess the solution I provided is correct.

Thanks

Regards,
Raja, USA

Lokeshbasana, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response