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

大家快来看看,这段代码
public void Del(int del)
  { 
  foreach(GridViewRow row in DisplayReport.Rows )
  {
  for (int i = 0; i < DisplayReport.Rows.Count; i++)
  {
  CheckBox chk = (CheckBox)row.FindControl("SelectChk");
  if (chk.Checked )
  {
  SqlConnection con = new SqlConnection("server=127.0.0.1;uid=sa;pwd=sa;database=myDb");
  con.Open();
  SqlCommand cmd = new SqlCommand("DelOneMessage", con);
  cmd.CommandType = CommandType.StoredProcedure;

  SqlParameter paramDel = new SqlParameter("@Del", SqlDbType.Int, 4);
  paramDel.Value = del;
  cmd.Parameters.Add(paramDel);
  con.Close();
   
  }
  }
  } 
  }

这段代码有错吗..删除不了记录呀,,,在线等,,,

------解决方案--------------------
小弟弟,你要执行的阿
cmd.executeNonQuery();
------解决方案--------------------
为什么要两重循环呢?
------解决方案--------------------
同上
没有执行语句咋可能删除?