473,320 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Escape character for C#

I am trying to get my select statement that is in a string variable to work
with alias column names I need a double quote " to go around some of the
aliases, however, they need to have a double quote around them to get the
sql to work correctly, how can you escape them out so that I can get them to
work within the string?

eri.actual_miles_qty AS "Last Odometer"

I dont want to use underscores.
Nov 16 '05 #1
4 1810

"Brian Conway" <Br**********@qwest.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I am trying to get my select statement that is in a string variable to work with alias column names I need a double quote " to go around some of the
aliases, however, they need to have a double quote around them to get the
sql to work correctly, how can you escape them out so that I can get them to work within the string?

eri.actual_miles_qty AS "Last Odometer"


"eri.actual_miles_qty AS \"Last Odometer\""

Nov 16 '05 #2
Brian,

If you are going against SQL server, then you should be using single
quotes, not double.

You probably shouldn't be doing this at all though. You should use
parameterized queries, as they will allow you to just specify the text, and
it will take care of formatting. This also protects you against SQL
injection attacks, which could have a very detrimental affect on your DB.

Take a look at the Parameters property on the SqlCommand, OleDbCommand,
OdbcCommand, OracleCommand classes (depending on which one you use), as this
is what you will use to create your parameterized query.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Brian Conway" <Br**********@qwest.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I am trying to get my select statement that is in a string variable to work with alias column names I need a double quote " to go around some of the
aliases, however, they need to have a double quote around them to get the
sql to work correctly, how can you escape them out so that I can get them to work within the string?

eri.actual_miles_qty AS "Last Odometer"

I dont want to use underscores.

Nov 16 '05 #3
Harlan
Well I tried yours that you listed and it still shows it as invalid.

Nick
Its going against an Oracle databse. Since I am using a Datagrid, I wanted
the headers to show up differently. These are parameters that I am making,
just column headings.

"Harlan Messinger" <h.*********@comcast.net> wrote in message
news:2i************@uni-berlin.de...

"Brian Conway" <Br**********@qwest.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I am trying to get my select statement that is in a string variable to work
with alias column names I need a double quote " to go around some of the
aliases, however, they need to have a double quote around them to get the sql to work correctly, how can you escape them out so that I can get

them to
work within the string?

eri.actual_miles_qty AS "Last Odometer"


"eri.actual_miles_qty AS \"Last Odometer\""

Nov 16 '05 #4
string MyString = "eri.actual_miles_qty AS \"Last Odometer\"";

This works on my system. Can you create a small snippet that fails to work
and we can take a look at the code in context?

--- Nick

"Brian Conway" <Br**********@qwest.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Harlan
Well I tried yours that you listed and it still shows it as invalid.

Nick
Its going against an Oracle databse. Since I am using a Datagrid, I wanted
the headers to show up differently. These are parameters that I am making,
just column headings.

"Harlan Messinger" <h.*********@comcast.net> wrote in message
news:2i************@uni-berlin.de...

"Brian Conway" <Br**********@qwest.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I am trying to get my select statement that is in a string variable to

work
with alias column names I need a double quote " to go around some of the aliases, however, they need to have a double quote around them to get the sql to work correctly, how can you escape them out so that I can get

them
to
work within the string?

eri.actual_miles_qty AS "Last Odometer"


"eri.actual_miles_qty AS \"Last Odometer\""


Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Jon Maz | last post by:
Hi, I have been getting hopelessly confused with escaping escape characters in JScript! All I want to do is write a simple funtion: function DoubleUpBackSlash(inputString) { ??????? }
7
by: teachtiro | last post by:
Hi, 'C' says \ is the escape character to be used when characters are to be interpreted in an uncommon sense, e.g. \t usage in printf(), but for printing % through printf(), i have read that %%...
18
by: Steve Litvack | last post by:
Hello, I have built an XMLDocument object instance and I get the following string when I examine the InnerXml property: <?xml version=\"1.0\"?><ROOT><UserData UserID=\"2282\"><Tag1...
4
by: Guadala Harry | last post by:
I need to place the following into a string... How can I properly escape the % " / < and > characters? <table width="100%" border="0" cellspacing="0" cellpadding="4px" class="hfAll"></Table> ...
7
by: Steve | last post by:
string str ="\"C:\Program Files\Internet Explorer\iexplore.exe\" -nohome" How can I remove charcter to string str = ="C:\Program Files\Internet Explorer\iexplore.exe -nohome"
12
by: Jeff S | last post by:
In a VB.NET code behind module, I build a string for a link that points to a JavaScript function. The two lines of code below show what is relevant. PopupLink = "javascript:PopUpWindow(" &...
15
by: pkaeowic | last post by:
I am having a problem with the "escape" character \e. This code is in my Windows form KeyPress event. The compiler gives me "unrecognized escape sequence" even though this is documented in MSDN....
131
by: Lawrence D'Oliveiro | last post by:
The "escape" function in the "cgi" module escapes characters with special meanings in HTML. The ones that need escaping are '<', '&' and '"'. However, cgi.escape only escapes the quote character if...
3
by: qilin | last post by:
I am trying to save a big text string into MySQL, but I guess i need escape the string firstly, anybody knows any escape function in c for that? or any other suggests ?
5
by: vlsidesign | last post by:
The printf function returns "warning: unknown escape sequence: \040" for a backslash-space combination. If the ascii decimal number for space is 32 and the backslash is 92, why this particular...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.