Home > Net >  $statement is modified into a string. The Format statement
$statement is modified into a string. The Format statement

Time:04-04

String sqlString=$" insert into Students (StudentName, Gender, Birthday, AttendanceNO, Stulmage, Age, Phone, StudentAddress) VALUES ({Students. StudentName}, {Students. Gender}, {Students. Birthday}, {Students. AttendanceNO}, {Students. Stulmage}, {Students. Age}, {Students. Phone}, {Students. StudentAddress}) ";

CodePudding user response:

The string. Format ("... {0}... {2}... {1}... {1} ", str0, str1, str2);
Will eventually get "... Str0... Str2... Str1... Str1
"Namely: according to the serial number of the parameters for the interpolation of the template to replace,

Say the topic, you this kind of circumstance, can consider to upgrade the c # version, update their knowledge base is a good thing,

CodePudding user response:

Your writing is quite good, there is no need to change,

CodePudding user response:

Just respond to come over, you have a problem that SQL, if must use splicing method generates SQL, so the numerical fields need to use quotation marks on two sides feel up, of course the best option is to use parameterized queries,
  •  Tags:  
  • C#
  • Related