这很愚蠢,但我正在为 sqlcommand 声明一个 sql 字符串,我必须将它全部写在一行上
string strSQL = "SELECT [Year],[Week No],StartDate,EndDate,Dept,[Clock No],RTRIM(Name)+' '+ RTRIM(initial) as Name,[Own Hours],[Other Hours],[Total Hours],[OT Premium] FROM [Wages].[CHHours] Where [Year]=@WageYear and [Week No]=@Week Order by [Year] DESC, [Week No] DESC,Dept,[Clock No]" ;
因为否则我会在不断的错误中得到换行符,但这看起来真的很难看而且难以阅读。在 vb 中,它会使用 &_ 继续,因为 c# 对空格不敏感(我想)我应该这样写
string strSQL = "SELECT [Year],[Week No],StartDate,EndDate,Dept,[Clock No],
RTRIM(Name)+' '+ RTRIM(initial) as Name,[Own Hours],[Other Hours],
[Total Hours],[OT Premium]
FROM [Wages].[CHHours]
Where [Year]=@WageYear and [Week No]=@Week
Order by [Year] DESC, [Week No] DESC,Dept,[Clock No]" ;
还是我必须这样做
string strSQL = "SELECT [Year],[Week No],StartDate,EndDate,Dept,[Clock No],";
string strSQL = strSQL+" RTRIM(Name)+' '+ RTRIM(initial) as Name,[Own Hours]";
string strSQL = strSQL+",[Other Hours],[Total Hours],[OT Premium] ";
string strSQL = strSQL+"FROM [Wages].[CHHours] ";
string strSQL = strSQL+" Where [Year]=@WageYear and [Week No]=@Week ";
string strSQL = strSQL+"Order by [Year] DESC, [Week No] DESC,Dept,[Clock No]" ;
这让我觉得很古老!
请伊恩最好的方法是什么