把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;
}