Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
StringBuilder AppendFormat function
Message
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 2.0
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01292192
Message ID:
01292237
Views:
45
>>Hi everybody,
>>
>>The following piece of code I would assume is supposed to put carriage return between each delete and insert, right?
>>
>>strSQL.AppendFormat("DELETE EventTargets WHERE EventID = {0}\n",
>>                e.Keys["EventID"]);
>>
>>            foreach (ListItem Item in lsbTargets.Items)
>>            {
>>                if (Item.Selected)
>>                {
>>                    strSQL.AppendFormat("INSERT INTO EventTargets VALUES({0},'{1}')\n",
>>                        e.Keys["EventID"], Item.Value);
>>                }
>>            }
>>
>>However, I see DELETE EventTargets where EventID=32INSERT... in the debugger. So, apparently my guess that \n is supposed to be CRLF is wrong.
>>
>>Or do you see what else may be wrong in this code?
>
>Try '\r\n'. But best practice is probably to use Environment.NewLine instead (or use the StringBuilder.AppendLine method)

Can you please show it for the newbie applying to this particular piece of code?

In the meantime the code seems to work correctly (in IE at least), just doesn't show correctly when I'm debugging. Same with \r\n

{DELETE EventTargets WHERE EventID = 32
INSERT INTO EventTargets VALUES(32,'A')
INSERT INTO EventTargets VALUES(32,'B')
INSERT INTO EventTargets VALUES(32,'D')
}
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform