SQL语句太长我想分行,用什么连接符阿?
例如这句 string cmd3 = "Update KHGL_Customer set cCusCode=@cCusCode,cCusName=@cCusName,cCusAbbName=@cCusAbbName,iDCID=@iDCID,cCusAddressMX=@cCusAddressMX,cCusSJName=@cCusSJName where iCustomerId= " + Temp;
我想把它从中间断开分两行写,中间用什么连接符阿?
[解决办法]
string cmd3 = "Update KHGL_Customer set CusCode=@cCusCode,cCusName=@cCusName, " +
"cCusAbbName=@cCusAbbName,iDCID=@iDCID,cCusAddressMX=@cCusAddressMX, " +
"cCusSJName=@cCusSJName where iCustomerId= " + Temp;
[解决办法]
// OR
string cmd3 = @ "Update KHGL_Customer set
cCusCode=@cCusCode,cCusName=@cCusName,cCusAbbName=@cCusAbbName,
iDCID=@iDCID,cCusAddressMX=@cCusAddressMX,cCusSJName=@cCusSJName
where iCustomerId= " + Temp;
[解决办法]
" "+
" "+
" "
[解决办法]
string cmd3 = "Update KHGL_Customer set "+
" cCusCode=@cCusCode,cCusName=@cCusName, "+
" cCusAbbName=@cCusAbbName, "+
" iDCID=@iDCID,cCusAddressMX=@cCusAddressMX, "+
" cCusSJName=@cCusSJName where iCustomerId= " + Temp;
[解决办法]
string cmd3 = "Update KHGL_Customer set CusCode=@cCusCode,cCusName=@cCusName, ";
cmd3 += "cCusAbbName=@cCusAbbName,iDCID=@iDCID,cCusAddressMX=@cCusAddressMX, "
cmd3 += "cCusSJName=@cCusSJName where iCustomerId= " + Temp;
[解决办法]
" "+
" "+
" "
或者StringBuild.Append()吧
[解决办法]
string cmd3 = @ "Update KHGL_Customer set
cCusCode=@cCusCode,cCusName=@cCusName,cCusAbbName=@cCusAbbName,
iDCID=@iDCID,cCusAddressMX=@cCusAddressMX,cCusSJName=@cCusSJName
where iCustomerId= " + Temp;
在双引号外加前导@符号允许你直接在字符串中间输入回车,不需要什么来连接.
至于用加号连接, 连加 比每次 += 要好,因为连加多个字符串 "常 "量时,最终生成的IL实际上是优化完直接赋值的,但用+= 就会造成多生成额外的IL