首页 新闻 会员 周边 捐助

对象不能从 DBNull 转换为其他类型。

0
[已关闭问题] 关闭于 2016-02-01 20:16
  for (int i = 0; i < dgvHead.Rows.Count; i++)
            {
                if (dgvHead.Rows[i].Cells[0].Value == null) 
                {
                    break;
                }
                string sql =
                    "insert product_desProductTime (fno,positation,worktimeNo,initialCount,seamDistance,endCount,worktimeName,samTime,target,equipment,tool) values('" + txtfNo.Text + "','头部','" + dgvHead.Rows[i].Cells[0].Value.ToString() + "'," +Convert.ToInt32(dgvHead.Rows[i].Cells[1].Value) + ","+Convert.ToInt32(dgvHead.Rows[i].Cells[2].Value)+"," +Convert.ToInt32(dgvHead.Rows[i].Cells[3].Value) + ",'" + dgvHead.Rows[i].Cells[4].Value.ToString() + "'," + Convert.ToDouble(dgvHead.Rows[i].Cells[5].Value) + ","+Convert.ToDouble(dgvHead.Rows[i].Cells[6].Value) + ",'" + dgvHead.Rows[i].Cells[7].Value.ToString() + "','" + dgvHead.Rows[i].Cells[8].Value.ToString() + "')";
                SqlHelp.ExecuteNonQuery(CommandType.Text, sql);
            }

为什么 我将datagridview中的数据写入到数据库的时候出现"对象不能从 DBNull 转换为其他类型。",虽然数据已经成功插入到DB中了

JaneEyreWork的主页 JaneEyreWork | 初学一级 | 园豆:11
提问于:2016-02-01 19:48
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册