Sql或String字符串太长的写法

示例:

 

string sqlUser ="insert into dbo.T_BAS_User(UserID, UserNo, UserName, UserPassPort, UserQuestion, UserAnswer, UserEmail, UserType, UserMemo)" + System.Environment.NewLine;
     sqlUser=sqlUser + " select " + System.Environment.NewLine;
     sqlUser=sqlUser + "'" + user.UserID +"'," + System.Environment.NewLine;
     sqlUser=sqlUser + "'" + user.UserNo +"'," + System.Environment.NewLine;
     sqlUser=sqlUser + "'" + user.UserName +"'," + System.Environment.NewLine;
     sqlUser=sqlUser + "'" + user.UserPassPort +"'," + System.Environment.NewLine;
     sqlUser=sqlUser + "'" + user.UserQuestion +"'," + System.Environment.NewLine;
     sqlUser=sqlUser + "'" + user.UserAnswer +"'," + System.Environment.NewLine;
     sqlUser=sqlUser + "'" + user.UserEmail +"'," + System.Environment.NewLine;
     sqlUser=sqlUser + "'" + user.UserType.ToString() +"'," + System.Environment.NewLine;
     sqlUser=sqlUser + "'" + user.UserMemo +"'" + System.Environment.NewLine;

 

这样即避免了太长,又能在断点操作的时候,使Sql语句不至于太长。

加了一个换行符。

你可能感兴趣的:(C#公用)