我有逐字字符串有一些变量contacanete with,我的问题我总是从编译器得到这个错误:
; expected
那我怎么能正确地逃脱呢?
int teacherId = sqlStatus = (int)sqlCmd.LastInsertedId;
sqlCmd.CommandText = @"INSERT INTO report (report_type, report_date, semester, report_details, teacher_id)
VALUES (0, ""2018-01-01"", 1, '{
""teacherId"": "" " + teacherId.ToString() + " "", <=== error here (; expected)
""mahderDate"": """",
""teacherShool"": """",
""baladia"": """",
""wilaya"": """",
""moufatecheReport"": """"
}'," + teacherId + ");";
答案 0 :(得分:0)
使用@poke建议我设法让它在行中放置双引号和@:
int teacherId = sqlStatus = (int)sqlCmd.LastInsertedId;
sqlCmd.CommandText = @"INSERT INTO report (report_type, report_date, semester, report_details, teacher_id)
VALUES (0, ""2018-01-01"", 1, '{
""teacherId"": "" " + teacherId.ToString() + "," +
@" ""mahderDate"": """",
""teacherShool"": """",
""baladia"": """",
""wilaya"": """",
""moufatecheReport"": """"
}'," + teacherId + ");";