Jasonchne
Jasonchne
采纳率73.7%
2019-08-28 17:33 阅读 461

断言失败:Adort=Quit、Retry=Debug、Ignore=Continue

把DataTable的中的数据导入到数据表中出错,提示断言失败:Adort=Quit、Retry=Debug、Ignore=Continue,前台报错截图如下:

图片说明

我看了一下后台代码可以获取数据,也可以插入数据到数据库,为什么前台会抛出此异常,求大神指点。
后台代码如下:

1、插入数据代码
   protected void Btn_JS_Click(object sender, EventArgs e)
        {
            //DataBinds1();
            CenterBaseDAL.ExecuteSql cbde = new CenterBaseDAL.ExecuteSql();
            DataTable dt = new DataTable();
            string sql = "select * from View_YPCG";
            dt = cbde.GetTab_Sql(sql);



            for (int i = 0; i < dt.Rows.Count; i++)
            {
                string yymc = dt.Rows[i][1].ToString();
                string kfmc = dt.Rows[i][5].ToString();
                string rkdh = dt.Rows[i][6].ToString();
                string fph = dt.Rows[i][7].ToString();
                string ypph = dt.Rows[i][8].ToString();
                string rkczy = dt.Rows[i][9].ToString();
                string rkrq = dt.Rows[i][10].ToString();
                string scrq = dt.Rows[i][11].ToString();
                string sxrq = dt.Rows[i][12].ToString();
                string jzczy = dt.Rows[i][13].ToString();
                string jzrq = dt.Rows[i][14].ToString();
                string ghdw = dt.Rows[i][15].ToString();
                string sccj = dt.Rows[i][16].ToString();
                string yplb = dt.Rows[i][17].ToString();
                string ypmc = dt.Rows[i][18].ToString();
                string ypgg = dt.Rows[i][19].ToString();
                string ypjj = dt.Rows[i][20].ToString();
                string ypsj = dt.Rows[i][21].ToString();
                string rksl = dt.Rows[i][22].ToString();
                string ypdw = dt.Rows[i][23].ToString();
                string jjzj = dt.Rows[i][24].ToString();
                string slzj = dt.Rows[i][25].ToString();
                string jxce = dt.Rows[i][26].ToString();
                string pzwh = dt.Rows[i][27].ToString();

                string sql1 = "insert into HJY_GYL_YPFX(yymc,kfmc,rkdh,fph,ypph,rkczy,rkrq,scrq,sxrq,jzczy,jzrq,ghdw,sccj,yplb,ypmc,ypgg,ypjj,ypsj,rksl,ypdw,jjzj,lszj,jxcj,pzwh) " +
                    "values('" + yymc + "'," + "'" + kfmc + "'," + "'" + rkdh + "'," + "'" + fph + "'," + "'" + ypph + "'," + "'" + rkczy + "'," + "'" + rkrq + "'," + "'" + scrq + "'," + "'" + sxrq + "'," + "'" + jzczy + "'," + "'" + jzrq + "'," + "'" + ghdw + "',"+"'" + sccj + "'," + "'" + yplb + "'," + "'" + ypmc + "'," + "'" + ypgg + "'," + "'" + ypjj + "'," + "'" + ypsj + "'," + "'" + rksl + "'," + "'" + ypdw + "'," + "'" + jjzj + "'," + "'" + slzj + "'," + "'" + jxce + "'," + "'" + pzwh + "'" + ")";
                int falg = cbde.run(sql1);
                if (falg == 1)
                {
                    CenterBaseTools.Common.Alert(this.Page, "还原成功!");
                }
                else
                {
                    CenterBaseTools.Common.Alert(this.Page, cbde.ErrorMessage);
                }

            }

            Response.Write("<script language=javascript>window.open('../YPCGJS.aspx')</script>");
        }
2、ExecuteSql代码
public DataTable GetTab_Sql(string sql)
        {
            ConfigManager config = new ConfigManager();
            DataTable dt = new DataTable();
            SqlDataAdapter sqldt = new SqlDataAdapter(sql, config.DALConnectionString);
            //this.ErrorMessage = sproc.ErrorMessage.ToString();
            sqldt.Fill(dt);

            return dt;
        }
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    Jasonchne Jasonchne 2019-08-29 14:26

    已解决,同意楼上观点,遇到问题只能自己先调试了。调试过程中我发现有一个参数一直不为NULL,更改该参数的判断条件,就没有“断言失败:Adort=Quit、Retry=Debug、Ignore=Continue”的错误提示了。

    点赞 评论 复制链接分享
  • caozhy 从今以后生命中的每一秒都属于我爱的人 2019-08-28 23:04

    以调试方式运行程序,检查下哪里触发了断言(assert)
    特别是你那个sql拼接,参数这些,还有是否和数据库的定义吻合

    点赞 评论 复制链接分享

相关推荐