c# "INSERT 语句中列的数目大于 VALUES 子句中指定的值的数目。VALUES 子句中值的数目必须与 INSERT 语句中指定的列的数目匹配解决方法。
出错原因是SQL语句 VALUES 值少了一个逗号
下面展示一些 内联代码片
。
public string sql = string.Format("INSERT INTO [dbo].[layout_17c01]" +
"(" +
"[xh]," +
"[fzjg]," +
"[glbm]," +
"[gxsj]) " +
"VALUES" +
"(" +
"'{0}'," +
"'{1}'," +
"'{2}'" +
"'{3}'," +
")",
PubilcCons.xhStr,
PubilcCons.fzjgStr,
PubilcCons.glbmStr,
PubilcCons.gxsjStr);
如下图所示
下面展示一些 内联代码片
。
public string sql = string.Format("INSERT INTO [dbo].[layout_17c01]" +
"(" +
"[xh]," +
"[fzjg]," +
"[glbm]," +
"[gxsj]) " +
"VALUES" +
"(" +
"'{0}'," +
"'{1}'," +
"'{2}'," +
"'{3}'," +
")",
PubilcCons.xhStr,
PubilcCons.fzjgStr,
PubilcCons.glbmStr,
PubilcCons.gxsjStr);