+ -
当前位置:首页 → 问答吧 → asp.net 批量输入问题

asp.net 批量输入问题

时间:2011-11-04

来源:互联网

我的代码出现问题,求解啊!
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)  
  {  
  string sqlstr = string.Format( "update selectc set sscore=" + ((TextBox)GridView1.Rows[i].Cells[5].FindControl("TextBox1")).Text + "where sid=" + GridView1.Rows[i].Cells[0].Text);
  OleDbCommand sqlcom = new OleDbCommand(sqlstr, coon);
问题提示是未将对象引用设置到对象的实例。

作者: tyfyang   发布时间: 2011-11-04

打断点单步调试吧

作者: zsx841021   发布时间: 2011-11-04

OleDbCommand有没有引包

作者: hefeng_aspnet   发布时间: 2011-11-04

给你看全一点的代码
OleDbConnection coon = new OleDbConnection();
  coon.ConnectionString = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + Server.MapPath("App_Data/db1.mdb");
  coon.Open();
  for (int i = 0; i <= GridView1.Rows.Count - 1; i++)  
  {  
  string str = string.Format( "update selectc set sscore=" + ((TextBox)GridView1.Rows[i].Cells[5].FindControl("TextBox1")).Text + "where sid=" + GridView1.Rows[i].Cells[0].Text);
  OleDbCommand com = new OleDbCommand(str, coon);
  com.ExecuteNonQuery();  
  }

作者: tyfyang   发布时间: 2011-11-04

热门下载

更多