Click here to Skip to main content
15,902,921 members
Home / Discussions / C#
   

C#

 
GeneralRe: Format SQL statement into C# string. Pin
Not Active19-Oct-09 9:19
mentorNot Active19-Oct-09 9:19 
GeneralRe: Format SQL statement into C# string. Pin
RK KL19-Oct-09 9:25
RK KL19-Oct-09 9:25 
GeneralRe: Format SQL statement into C# string. Pin
Not Active19-Oct-09 9:58
mentorNot Active19-Oct-09 9:58 
GeneralRe: Format SQL statement into C# string. Pin
RK KL19-Oct-09 10:13
RK KL19-Oct-09 10:13 
GeneralRe: Format SQL statement into C# string. Pin
Brady Kelly19-Oct-09 11:21
Brady Kelly19-Oct-09 11:21 
GeneralRe: Format SQL statement into C# string. Pin
Not Active19-Oct-09 11:51
mentorNot Active19-Oct-09 11:51 
GeneralRe: Format SQL statement into C# string. Pin
PIEBALDconsult19-Oct-09 15:37
mvePIEBALDconsult19-Oct-09 15:37 
AnswerRe: Format SQL statement into C# string. PinPopular
AspDotNetDev19-Oct-09 10:25
protectorAspDotNetDev19-Oct-09 10:25 
C#
string sql = @"
   	    select *
	    From Status 
	    From ActivityStatus ActStsId=StsId";



Putting an @ in front of a string makes it a multi-line string. Whitespace is preserved (including newlines). If you had a quote character in your SQL, you'd have to escape it by typing a two of them (you could do this with a quick find-replace in Notepad before pasting into C#).

But like others have said, typically a bad idea to put SQL in C# code. Some environments don't have stored procedures (like SQL Server CE), in which case I'd recommend storing the SQL in your settings as a string setting. You can then reference it by the setting name in your code.

Visual Studio is an excellent GUIIDE.

GeneralRe: Format SQL statement into C# string. Pin
Mycroft Holmes19-Oct-09 12:23
professionalMycroft Holmes19-Oct-09 12:23 
QuestionA problem with namespace? Pin
George Quarton19-Oct-09 5:15
George Quarton19-Oct-09 5:15 
AnswerRe: A problem with namespace? Pin
Luc Pattyn19-Oct-09 6:12
sitebuilderLuc Pattyn19-Oct-09 6:12 
GeneralRe: A problem with namespace? Pin
George Quarton19-Oct-09 6:31
George Quarton19-Oct-09 6:31 
GeneralRe: A problem with namespace? Pin
Luc Pattyn19-Oct-09 6:48
sitebuilderLuc Pattyn19-Oct-09 6:48 
GeneralRe: A problem with namespace? Pin
Luc Pattyn19-Oct-09 9:16
sitebuilderLuc Pattyn19-Oct-09 9:16 
GeneralRe: A problem with namespace? Pin
George Quarton19-Oct-09 11:50
George Quarton19-Oct-09 11:50 
QuestionReplication Classes Pin
md_refay19-Oct-09 4:37
md_refay19-Oct-09 4:37 
QuestionCustomer user control load screen Pin
gdub19-Oct-09 4:24
gdub19-Oct-09 4:24 
AnswerRe: Customer user control load screen Pin
Not Active19-Oct-09 4:55
mentorNot Active19-Oct-09 4:55 
AnswerRe: Customer user control load screen Pin
benjymous19-Oct-09 4:55
benjymous19-Oct-09 4:55 
GeneralRe: Customer user control load screen Pin
Not Active19-Oct-09 5:47
mentorNot Active19-Oct-09 5:47 
GeneralRe: Customer user control load screen Pin
gdub19-Oct-09 7:23
gdub19-Oct-09 7:23 
GeneralRe: Customer user control load screen Pin
Not Active19-Oct-09 7:49
mentorNot Active19-Oct-09 7:49 
QuestionLow priority: Visual Studio IDE, string literals, convenience. Pin
LimitedAtonement19-Oct-09 3:42
LimitedAtonement19-Oct-09 3:42 
AnswerRe: Low priority: Visual Studio IDE, string literals, convenience. Pin
Luc Pattyn19-Oct-09 5:09
sitebuilderLuc Pattyn19-Oct-09 5:09 
GeneralRe: Low priority: Visual Studio IDE, string literals, convenience. Pin
LimitedAtonement19-Oct-09 5:33
LimitedAtonement19-Oct-09 5:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.