首先,你用的不是sqlserver,而是access
其次
你把这句放出来
string sqlstr="update info set name='"+name.Text+"',age="+age.Text+",gender="+gender.Text+",jiguan='"+jiguan.Text+"',tel="+tel.Text+" where id ="+e.Item.Cells[0].Text+";";
而且帮你稍作了修改,int类型的不用加'',char类型的要加''
把这句注释起来
//string sqlstr="update info set name=?,age=?,gender=?,jiguan=?,tel=? where id = "+e.Item.Cells[0].Text;
试试
其次
你把这句放出来
string sqlstr="update info set name='"+name.Text+"',age="+age.Text+",gender="+gender.Text+",jiguan='"+jiguan.Text+"',tel="+tel.Text+" where id ="+e.Item.Cells[0].Text+";";
而且帮你稍作了修改,int类型的不用加'',char类型的要加''
把这句注释起来
//string sqlstr="update info set name=?,age=?,gender=?,jiguan=?,tel=? where id = "+e.Item.Cells[0].Text;
试试
解决方案 »
- 【请教】模板页中使用ajaxpro出现的问题
- c#.net 怎样使用二进制大对象
- 从FTP上自动检测数据,有新数据自动导入数据库
- ASP.NET输入的时候既可输入文本,又可输入图片
- 生成静态页面的解决方案
- >>>求助<<< 如何可以使得无论打开 Web 应用程序中的任何页面,都会执行同一段代码?
- DataList 如何绑定 DataReader的数据?
- 大虾们,有问题帮着解决一下,在此先谢了!
- 为什么这样的分页语句会在access 和mssql中汇报错?????
- 求大神指导,在ASP.NET 中用CKEditor,上传图片时点击上传到服务器显示“Internet无法显示”
- SqlParameter 问题
- C#中SQL参数传递问题,急!!!!!!!!!
{
string name,gender,jiguan,tel,age;
TextBox txtname,txtage,txtgender,txtjiguan,txttel;
txtname=(TextBox)e.Item.Cells[1].Controls[0];
txtage=(TextBox)e.Item.Cells[2].Controls[0];
txtgender=(TextBox)e.Item.Cells[3].Controls[0];
txtjiguan=(TextBox)e.Item.Cells[4].Controls[0];
txttel=(TextBox)e.Item.Cells[5].Controls[0];
name=txtname.Text;
age=txtage.Text;
gender=txtgender.Text;
jiguan=txtjiguan.Text;
tel=txttel.Text;
string dbpath=@"student.mdb";
string connstr="PROVIDER=Microsoft Jet OLEDB.4.0;DATA Source="+Server.MapPath(dbpath)+";";
OleDbConnection myconn=new OleDbConnection(connstr);
string sqlstr="update info set [name] = '"+name+"',age ='"+age+"',gender ='"+gender+"',jiguan ='"+jiguan+"',tel ='"+tel+"' where id ="+e.Item.Cells[0].Text;
OleDbCommand mycommupt=new OleDbCommand(sqlstr,myconn);
myconn.Open();
mycommupt.ExecuteNonQuery();
myconn.Close();
DataGrid1.EditItemIndex =-1;
bind(); }我改成上面这样,点更新的时候----
异常详细信息: System.ArgumentOutOfRangeException: 指定的参数已超出有效值的范围。参数名: index源错误:
行 80:
行 81: TextBox txtname,txtage,txtgender,txtjiguan,txttel;
行 82: txtname=(TextBox)e.Item.Cells[1].Controls[0];
行 83: txtage=(TextBox)e.Item.Cells[2].Controls[0];
行 84: txtgender=(TextBox)e.Item.Cells[3].Controls[0];谁帮帮我