解决方案 »

  1.   

    如果你的语句没问题,就不会跳到catch里面
    ExecuteNonQuery 指的是受影响的行数,如果没有删除数据,则受影响的行数为0
    所以你判断是否删除成功应该从受影响行数是否为0来判断
      

  2.   


    if(list.Count>1){//多条数据的
                string instr = "(";
                for (int i = 0; i < list.Count;i++ )
                {
                    instr+=list[i]+",";
                }
                instr = instr.Remove(instr.LastIndexOf(","), 1);//截逗号//s1 = s1.Substring(0, s1.Length-1); //去掉最后
                instr += ")";
                string muti_sqlstr = string.Format("DELETE FROM TB_ResidentBaseInfo WHERE ID IN {0}",instr);
                int rows = DbHelperSQL.ExecuteSql(muti_sqlstr);
                if (rows > 1)//因为至少都是2条
                {
                    X.Msg.Alert("提示", "成功删除" + rows + "条数据").Show();
                    this.Store1.DataSource = this.GetDataTable();
                    this.Store1.DataBind();//重新绑定数据
                }
                else
                {
                    X.Msg.Alert("提示", "删除失败").Show(); 
                }
               
                
            }else{//单条数据的
                string singal_sql =string.Format( " DELETE FROM TB_ResidentBaseInfo WHERE ID='{0}'",list[0]);
                int sinrows = DbHelperSQL.ExecuteSql(singal_sql);
                if (sinrows > 0)
                {
                    X.Msg.Alert("提示", "成功删除1条数据").Show();
                    this.Store1.DataSource = this.GetDataTable();
                    this.Store1.DataBind();//重新绑定数据
                }else{
                    X.Msg.Alert("提示", "删除失败").Show(); 
                }
            }
      

  3.   

    你先不打断电,用Profiler来跟踪一下你整个删除过程调用的真实语句,分析一下是否T-SQL问题,还是说C#问题