Connecting Tech Pros Worldwide Forums | Help | Site Map

New line code doesn't work

STom
Guest
 
Posts: n/a
#1: Nov 16 '05
Here is the code I have:

String strCmd = "";

strCmd = strCmd + "CREATE PROCEDURE GetAllModels2" + "\r\n";
strCmd = strCmd + "AS";
strCmd = strCmd + "BEGIN" + "\r\n";
strCmd = strCmd + "SELECT * FROM tblModels" + "\r\n";
strCmd = strCmd + "END" + "\r\n";
strCmd = strCmd + "GO";

When I look at strCmd in the command window, I still see the \r\n characters. I want new lines. Am I doing something wrong here?

Thanks.

STom




Richard A. Lowe
Guest
 
Posts: n/a
#2: Nov 16 '05

re: New line code doesn't work


You're doing the right thing, the command window just shows strings that way
(at least by default, maybe there's a way to change it?)

--
C#, .NET and Complex Adaptive Systems:
http://blogs.geekdojo.net/Richard
"STom" <stombiztalker@hotmail.com> wrote in message
news:ucweBDy%23EHA.3376@TK2MSFTNGP12.phx.gbl...
Here is the code I have:

String strCmd = "";
strCmd = strCmd + "CREATE PROCEDURE GetAllModels2" + "\r\n";
strCmd = strCmd + "AS";
strCmd = strCmd + "BEGIN" + "\r\n";
strCmd = strCmd + "SELECT * FROM tblModels" + "\r\n";
strCmd = strCmd + "END" + "\r\n";
strCmd = strCmd + "GO";
When I look at strCmd in the command window, I still see the \r\n
characters. I want new lines. Am I doing something wrong here?
Thanks.
STom


yyy
Guest
 
Posts: n/a
#3: Nov 16 '05

re: New line code doesn't work


Try it with just "\n"

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nurchi BECHED
Guest
 
Posts: n/a
#4: Nov 16 '05

re: New line code doesn't work


No, it is, by far, not redundant.
If you open a text file, type something, save,
and look at the file size, then add a new line
by pressing Enter, you will notice, that file size
increases by 2, not by 1.
\r is caret return
\n is a new line
if one of them is missing, the file may open properly
in one environment, but in another, you will see
some crap (boxes or smth like that) at the end of lines...

It is necessary.
The best way to go is:
<code>
string NewLine=System.Environment.NewLine;
String strCmd = "";

strCmd = strCmd + "CREATE PROCEDURE GetAllModels2" + NewLine;
strCmd = strCmd + "AS";
strCmd = strCmd + "BEGIN" + NewLine;
strCmd = strCmd + "SELECT * FROM tblModels" + NewLine;
strCmd = strCmd + "END" + NewLine;
strCmd = strCmd + "GO";
</code>
And don't you need a new line or a space after "AS"?



On Sat, 15 Jan 2005 23:56:15 +0100, Teis Draiby
<teisREMOVE-THIS@draiby.com> wrote:
[color=blue]
> What is the reason that you normally use \r\n rather than always \n.
> Isn't
> that kindof... redundant?
>
> Teis
>
>
>
>
> "yyy" <maxvizel@bezeqint-dot-net.no-spam.invalid> wrote in message
> news:41e958cb$1_2@Usenet.com...[color=green]
>> Try it with just "\n"
>>
>> *-----------------------*
>> Posted at:
>> www.GroupSrv.com
>> *-----------------------*[/color]
>
>[/color]



--
Regards,
Nurchi BECHED
Jon Skeet [C# MVP]
Guest
 
Posts: n/a
#5: Nov 16 '05

re: New line code doesn't work


STom <stombiztalker@hotmail.com> wrote:[color=blue]
> Here is the code I have:
>
> String strCmd = "";
>
> strCmd = strCmd + "CREATE PROCEDURE GetAllModels2" + "\r\n";
> strCmd = strCmd + "AS";
> strCmd = strCmd + "BEGIN" + "\r\n";
> strCmd = strCmd + "SELECT * FROM tblModels" + "\r\n";
> strCmd = strCmd + "END" + "\r\n";
> strCmd = strCmd + "GO";
>
> When I look at strCmd in the command window, I still see the \r\n
> characters. I want new lines. Am I doing something wrong here?[/color]

See http://www.pobox.com/~skeet/csharp/s....html#debugger

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Closed Thread