日期:2014-05-18  浏览次数:20520 次

继续弱弱的问,批量提交gridview的数据!
一个gridview,里面有n个模板列,每个模板列里有一个textbox。在查询表后有n条记录,在给textbox赋值后全部对数据库表进行更新。
表[zu-name]的结构是:
id zuname username fen1 fen2 fen3 fen4 fen5 zongfen

我的语句是: string str1 = "update [zu-username] set fen1='" + ((TextBox)GridView1.Rows[i].Cells[3].FindControl("textbox1")).Text.ToString().Trim() + "',fen2='" + ((TextBox)GridView1.Rows[i].Cells[3].FindControl("textbox2")).Text.ToString().Trim() + "',fen3='" + ((TextBox)GridView1.Rows[i].Cells[3].FindControl("textbox3")).Text.ToString().Trim() + "',fen4='" + ((TextBox)GridView1.Rows[i].Cells[3].FindControl("textbox5")).Text.ToString().Trim() + "',fen5='" + ((TextBox)GridView1.Rows[i].Cells[3].FindControl("textbox4")).Text.ToString().Trim() + "' where id in(select id from [zu-username] where username='" + this.GridView1.Rows[i].Cells[0].ToString() + "')";
更新不了记录。。。是不是写的有错误?

------解决方案--------------------
先直接把语句输出来,再放到查询分析器里面去运行,就知道行不行!