protected void OnRowUpdatingEvent(Object sender, GridViewUpdateEventArgs e)
{
//Response.Write("<script>alert('" + ds.Tables["图书借阅"].Rows[e.RowIndex]["借阅编号"].ToString() + "!')</script>");
int res = -1;
if (updateCmd == null || GridView1 == null)
return;
try
{
// for (int i = 0; i < 6; i++)
// Response.Write("<script>alert('" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[0].Controls[0])).Text.ToString().Trim() + "!')</script>"); updateCmd.CommandText = @"UPDATE 图书借阅 SET 读者编号=" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim() + ",图书编号=" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim()
+ ",借阅时间='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim() + "',应还时间='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim() + "',剩余可续借次数=" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim() + " WHERE 借阅编号=" + ds.Tables["图书借阅"].Rows[e.RowIndex]["借阅编号"].ToString() + ";";
updateCmd.Connection = conn;
res = updateCmd.ExecuteNonQuery();
//updateCmd.CommandText.Replace('\'', 'x');
//Response.Write("<script>alert(' res = " + updateCmd.CommandText + "!')</script>");
Response.Write("<script>alert(' res = " + res.ToString() + "!')</script>");
}catch(Exception ex)
{
Response.Write("<script>alert('" + ex.ToString() + "!')</script>");
}
GridView1.EditIndex = -1;
Bind();
}
protected void Bind()
{
adapter.SelectCommand.CommandText = @"SELECT * FROM 图书借阅";
if (ds.Tables["图书借阅"] != null)
ds.Tables["图书借阅"].Clear(); adapter.Fill(ds, "图书借阅");
GridView1.DataSource = ds.Tables["图书借阅"];
GridView1.DataBind();
}
返回受影响行数为1,但数据库中的值并没有改变是怎么回事?
{
//Response.Write("<script>alert('" + ds.Tables["图书借阅"].Rows[e.RowIndex]["借阅编号"].ToString() + "!')</script>");
int res = -1;
if (updateCmd == null || GridView1 == null)
return;
try
{
// for (int i = 0; i < 6; i++)
// Response.Write("<script>alert('" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[0].Controls[0])).Text.ToString().Trim() + "!')</script>"); updateCmd.CommandText = @"UPDATE 图书借阅 SET 读者编号=" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim() + ",图书编号=" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim()
+ ",借阅时间='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim() + "',应还时间='" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim() + "',剩余可续借次数=" + ((TextBox)(GridView1.Rows[e.RowIndex].Cells[5].Controls[0])).Text.ToString().Trim() + " WHERE 借阅编号=" + ds.Tables["图书借阅"].Rows[e.RowIndex]["借阅编号"].ToString() + ";";
updateCmd.Connection = conn;
res = updateCmd.ExecuteNonQuery();
//updateCmd.CommandText.Replace('\'', 'x');
//Response.Write("<script>alert(' res = " + updateCmd.CommandText + "!')</script>");
Response.Write("<script>alert(' res = " + res.ToString() + "!')</script>");
}catch(Exception ex)
{
Response.Write("<script>alert('" + ex.ToString() + "!')</script>");
}
GridView1.EditIndex = -1;
Bind();
}
protected void Bind()
{
adapter.SelectCommand.CommandText = @"SELECT * FROM 图书借阅";
if (ds.Tables["图书借阅"] != null)
ds.Tables["图书借阅"].Clear(); adapter.Fill(ds, "图书借阅");
GridView1.DataSource = ds.Tables["图书借阅"];
GridView1.DataBind();
}
返回受影响行数为1,但数据库中的值并没有改变是怎么回事?
解决方案 »
- wcf 服务返回异常This could be due to the service endpoint binding not using the HTTP..
- 请教一下MVC3的路由设置问题
- 问一个HTML中frame的问题
- 回车后按纽或得焦点
- 提供大家产生1000万记录的SQL,测试SELECT速度
- ★★★★急!SQL 2000小问题★★★
- GridView导出为Excel时出现乱码。很奇怪的事情。
- windows xp Pro版本的ISS中,怎么没有新建站点一项呀?
- 请问有没有xml的在线编辑器,就像html在线编辑器那样的
- 求救,在线等待!!!
- 怎么去统计一篇文章被浏览的次数
- 求aspnetpage 存储过程MSSQL
UPDATE 图书借阅 SET 读者编号='999',图书编号=" + ((TextBox)(......
跟踪出来sql语句。
去数据库里执行一下。
看看是哪里的问题