这是我在网格视图中更新的 coe。当我执行它时,编辑命令可以正常工作,但是当我单击更新时,我的 cmd.ExecuteNonQuery() 旁边会弹出此错误;“无法将参数值从字符串转换为十进制。” 请在这里帮助我。如果我有另一种方法可以将详细信息添加到数据库中,请提前告诉我谢谢。:)
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string v = System.Configuration.ConfigurationManager.ConnectionStrings["harish"].ConnectionString;
con = new OracleConnection(v);
con.Open();
string query = "update leave_module1 set name=:name,desig=:desig,srno=:srno,tol=:tol,compdates=:compdates,fd=:fd,td=:td,noofdays=:nod,remarks=:remarks";
OracleCommand cmd = new OracleCommand(query, con);
cmd.Parameters.Add(":name", OracleType.VarChar, 50).Value = GridView1.Rows[e.RowIndex].Cells[0].Text;
cmd.Parameters.Add(":desig", OracleType.VarChar, 30).Value = GridView1.Rows[e.RowIndex].Cells[1].Text;
cmd.Parameters.Add(":srno", OracleType.Number, 8).Value = GridView1.Rows[e.RowIndex].Cells[2].Text;
cmd.Parameters.Add(":tol", OracleType.VarChar, 10).Value = GridView1.Rows[e.RowIndex].Cells[3].Text;
cmd.Parameters.Add(":compdates", OracleType.VarChar, 30).Value = GridView1.Rows[e.RowIndex].Cells[4].Text;
cmd.Parameters.Add(":fd", OracleType.DateTime).Value = GridView1.Rows[e.RowIndex].Cells[5].Text;
cmd.Parameters.Add(":td", OracleType.DateTime).Value = GridView1.Rows[e.RowIndex].Cells[6].Text;
cmd.Parameters.Add(":nod", OracleType.Number, 3).Value = GridView1.Rows[e.RowIndex].Cells[7].Text;
cmd.Parameters.Add(":remarks", OracleType.VarChar, 50).Value = GridView1.Rows[e.RowIndex].Cells[8].Text;
cmd.ExecuteNonQuery();
ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('The Data has been added');window.location='Default2.aspx';</script>;");
cmd.Dispose();
con.Close();
}