for (int i = 0; i < GridView1.Rows.Count; i++) 
        { 
            StringBuilder query = new StringBuilder(); 
注意到没有这里每次query都是新的,都会重新new一次。

解决方案 »

  1.   

    StringBuilder query = new StringBuilder(); 
    放在for循环外面
      

  2.   

    不行标准表达式中数据类型不匹配。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.Exception: 标准表达式中数据类型不匹配。源错误: 
    行 91:             query.Append("update student set sno='"+sno+"',sname='"+sname+"',sex='"+sex+"' where ID='" + GridView1.DataKeys[i].Value + "'");
    行 92:         
    行 93:             Common.Common.ExecuteSql(query.ToString());
    行 94:         }
    行 95:         bind();
     
      

  3.   

    for (int i = 0; i < GridView1.Rows.Count; i++) 
            { 
                StringBuilder query = new StringBuilder(); 
              
                GridViewRow row = GridView1.Rows[i]; 
              
                string sno = ((TextBox)row.Cells[0].FindControl("sno")).Text.Replace("'", ""); 
              
                string sname = ((TextBox)row.Cells[0].FindControl("sname")).Text.Replace("'", ""); 
              
                string sex = ((DropDownList)row.Cells[0].FindControl("msex")).SelectedValue;           
            //打短点看下你这个生成的SQL语句最后是什么
             query.Append("update student set sno='" + sno + "',sname='" + sname+ "',sex='" + sex+ "' where ID='" + GridView1.DataKeys[i].Value + "'"); 
      

  4.   

    数据类型不匹配的话就可能是sno 或 ID 有一个不是int类型的,你单步调试下试试
      

  5.   

    你是说在数据哭查询分析器里吧
    我用的是access