string insertCommand =
"INSERT INTO Users (UserID) VALUES" + "" + "(CONVERT(uniqueidentifier, '" +
UsersIdentityToinsert + "'),'"+ userName+",0,null')";
它告诉我:问题的SQL语句
在VALUES子句中There are fewer columns in the INSERT statement than values specified
。 VALUES子句中的 值的数量必须与 INSERT语句中指定的列数相匹配 。
但我有四列?
如果我们使用参数,它会工作得更好,所以我们可以防范sql注入和丑陋的代码。 :) – 2011-06-06 06:03:56
嗯。你是否说我需要声明@Username,UniqueIdentifier ..然后将它们设置为值....会阻止sql的攻击? – WithFlyingColors 2011-06-06 06:11:30
sql注入是一个有效的点,但不仅仅是声明它们 - 你应该验证你所得到的任何值 – Beno 2011-06-06 06:13:27