想飞的鱼丶 2016-07-26 05:03 采纳率: 0%
浏览 1566

为什么ExecuteNonQuery返回0,数据里没改

删除按钮
protected void btnDelete_Click(object sender, EventArgs e)
{
string id = "";
foreach(GridViewRow item in GridView1.Rows)
{

CheckBox cb =(CheckBox)item.FindControl("ck");
if (cb.Checked)
{
id+= item.Cells[2].Text+",";
}
}
string BM=id.TrimEnd(',');
string sql = "delete from tb_bookInfo where bookBarCode in(@code)";
SqlParameter[] para ={
new SqlParameter("@code",BM)
};

if(BLL.Delete.ExecuteNonQuery(sql,para)>0)
{
GetBook();
this.ClientScript.RegisterStartupScript(this.GetType(), "", "alert('删除成功')", true);
}

    }

   if (co.State == ConnectionState.Closed)
       {
           co.Open();
       }
       SqlCommand comm = new SqlCommand(sql,co);
       comm.Parameters.AddRange(para);
       try
       {
             int i = comm.ExecuteNonQuery();
             return i;   
       }
       catch (Exception)
       {

           throw;
       }

数据库里的@code对应的是varchar,
调试时发现@code是(111111,1111112)
数据库里必须是(‘111111’,‘11111112’)才能执行

  • 写回答

1条回答 默认 最新

  • Go 旅城通票 2016-07-26 05:41
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记