Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

carriage return/line feed

Status
Not open for further replies.

lfc77

Programmer
Aug 12, 2003
218
GB
How do I include carriage return/line feeds in my SQL strings?

I currently have code in this format :

strCallTypeUpdate = "declare @Number as char(26) " + "\r\n "; (and so on...)

But this doesn't work. Is there an equivalent to vbCrLf in C#?


Thanks,

lfc77
 
lfc77,
You should use Environment.NewLine!

JC

Jesus Christ! I was unaware of all the smileys available here at tek-tips.
[rockband]
 
Your code should work!
Environment.NewLine is exactly "\r\n";
The followings are equivalent in C#:
Code:
Environment.NewLine; 
"\r\n";
(char)13 + (char)10;
Example:
Code:
cmd.CommandText = "CREATE PROCEDURE getProducts " + Environment.NewLine +
                    "@CatID Int " + Environment.NewLine +
                    "AS " + Environment.NewLine +
                    "SELECT ID, Desc, Price, Stock " +
                    "FROM NWA.dbo.Products " +
                    "WHERE ID = @CatID"
-obislavu-
 
But Environment.NewLine isolates you from the platform. If you run your code under Mono, it will produce the correct newline character sequence for your OS.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top