日期:2014-05-18  浏览次数:20470 次

谁帮我看看这条命令到底哪里错了啊,是关于INSERT的
string sql1 = "INSERT INTO PLAYER_SOLUTION(PLAYER_SOL_ID,PLAYER_SOL,PLAYER_DATE,PLAYER_TIMEUSE(s),PLAYER_EMAIL,SUDOKU_ID) VALUES ( '" + player_sol_ID + "','" + player_Sol + "','" + date + "','" + timeUse + "','" + email + "','" + sudoku_ID + "')";

SqlCommand cmd1 = new SqlCommand(sql1, conn);
cmd1.ExecuteNonQuery();


报错说Incorrect syntax near '('.



这里除了 date 是datetime , timeuse是 int 其他都是string  




------解决方案--------------------
string sql1 = "INSERT INTO PLAYER_SOLUTION(PLAYER_SOL_ID,PLAYER_SOL,PLAYER_DATE,[PLAYER_TIMEUSE(s)],PLAYER_EMAIL,SUDOKU_ID) VALUES ( '" + player_sol_ID + "','" + player_Sol + "','" + date.ToLongString() + "','" + timeUse + "','" + email + "','" + sudoku_ID + "')";

------解决方案--------------------
楼主,你检查下'(',附近的标点符号的,大小写,再试试
------解决方案--------------------
这种提示主要是语法错误,符号的半角全角或者是少了多了,更正我上面说的大小写。
------解决方案--------------------
上面的方法我不说了,然后你的问题和int没什么关系,主要是(或者''这里出问题,我很少用编程语言,所以具体语法我不记得了,建议你可以加上一个打印的功能,先不执行,把语句打印出来放到查询分析器或者SSMS中看看有没有语法错误,一般这种拼接都是需要''xxx''甚至'''xxx'''。你要多尝试,同时建议你编写成存储过程,这样出错机会少很多。
------解决方案--------------------
string sql1 = "INSERT INTO PLAYER_SOLUTION(PLAYER_SOL_ID,PLAYER_SOL,PLAYER_DATE,PLAYER_TIMEUSE(s),PLAYER_EMAIL,SUDOKU_ID) VALUES ( '" + player_sol_ID + "','" + player_Sol + "','" + date.ToString() + "','" + timeUse + "','" + email + "','" + sudoku_ID + "')";