473,403 Members | 2,359 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,403 software developers and data experts.

New line code doesn't work

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

Nov 16 '05 #1
4 4681
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" <st***********@hotmail.com> wrote in message
news:uc****************@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
Nov 16 '05 #2
yyy
Try it with just "\n"

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 16 '05 #3
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
<te*************@draiby.com> wrote:
What is the reason that you normally use \r\n rather than always \n.
Isn't
that kindof... redundant?

Teis


"yyy" <ma******@bezeqint-dot-net.no-spam.invalid> wrote in message
news:41**********@Usenet.com...
Try it with just "\n"

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*



--
Regards,
Nurchi BECHED
Nov 16 '05 #4
STom <st***********@hotmail.com> wrote:
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?


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

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5

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

Similar topics

10
by: Jack | last post by:
I'm trying to make a script that will search a list of files and remove the following line <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>"> I'm doing this...
1
by: Koen | last post by:
Hi all, I created a little database to manage my e-books. The program will synchronize a table with the contents of a directory. Works great. Because I keep additional info (like keywords) to...
23
by: FrancisC | last post by:
#include <stdio.h> int file_copy( char *oldname, char *newname ); int main() { char source, destination; printf("\nEnter source file: ");
65
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second...
6
by: Nurchi BECHED | last post by:
Hello, All! I have created an application with a multiline textbox on the form. When I press a button, it has to show something and then break the line and show something else. I tried "\n",...
22
by: DraguVaso | last post by:
Hi, For my application I need the following behavior: When I press F4 the cursor has to move to the next line in my multiline textbox which begins with "0". Finding lines starting with 0 isn't...
2
by: Eric Lilja | last post by:
Hello, I'm writing a simple program that upon start-up needs to open a text file and read a value on the last line. Then all other accesses to the file will be writes (at the end of it). I'm having...
12
by: e271828 | last post by:
Hi, I'm helping to work a developer tool that verifies a given HTML element has a given attribute (e.g., that all LABEL elements have a FOR attribute, all INPUT elements have an ID attribute,...
5
by: fidtz | last post by:
The code: import codecs udlASCII = file("c:\\temp\\CSVDB.udl",'r') udlUNI = codecs.open("c:\\temp\\CSVDB2.udl",'w',"utf_16") udlUNI.write(udlASCII.read()) udlUNI.close()
2
by: fhwa | last post by:
ok, I'm trying to write a string code and currently the code works however I've run out of room and I need to change some of the source names it pulls from. Changing the source names create the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.