急!!!!!索引超出范围。必须为非负值并小于集合大小。有具体程序,帮忙分析下,谢谢!
usingSystem;usingSystem.Configuration;usingSystem.Data;usingSystem.Linq;usingSystem.W...
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String conString = "provider = Microsoft.Ace.OLEDB.12.0 ; Data Source =" + MapPath("App_Data/数据.accdb");
OleDbConnection con = new OleDbConnection();
con.ConnectionString = conString;
OleDbCommand command = new OleDbCommand();
command.Connection = con;
String sqlString = "select * from Student_Information";
command.CommandText = sqlString;
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(command);
DataTable dt = new DataTable();
dataAdapter.Fill(dt);
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
String conString = "provider = Microsoft.Ace.OLEDB.12.0 ; Data Source = " + MapPath("App_Data/数据.accdb");
OleDbConnection con = new OleDbConnection();
con.ConnectionString = conString;
OleDbCommand command = new OleDbCommand();
command.Connection = con;
string id = GridView1.DataKeys[e.RowIndex].Values[0].ToString();
string SqlStr = "delete from Student_Information where Student_ID=" + "'" + id + "'";
command.CommandText = SqlStr;
con.Open();
command.ExecuteNonQuery();
con.Close(); Response.Redirect("\\新建 公文包\\Default.aspx");
Response.End();
}
protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)
{
}
}
string id = GridView1.DataKeys[e.RowIndex].Values[0].ToString();被指出如标题所示问题,应该怎么改呢? 展开
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String conString = "provider = Microsoft.Ace.OLEDB.12.0 ; Data Source =" + MapPath("App_Data/数据.accdb");
OleDbConnection con = new OleDbConnection();
con.ConnectionString = conString;
OleDbCommand command = new OleDbCommand();
command.Connection = con;
String sqlString = "select * from Student_Information";
command.CommandText = sqlString;
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(command);
DataTable dt = new DataTable();
dataAdapter.Fill(dt);
this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
String conString = "provider = Microsoft.Ace.OLEDB.12.0 ; Data Source = " + MapPath("App_Data/数据.accdb");
OleDbConnection con = new OleDbConnection();
con.ConnectionString = conString;
OleDbCommand command = new OleDbCommand();
command.Connection = con;
string id = GridView1.DataKeys[e.RowIndex].Values[0].ToString();
string SqlStr = "delete from Student_Information where Student_ID=" + "'" + id + "'";
command.CommandText = SqlStr;
con.Open();
command.ExecuteNonQuery();
con.Close(); Response.Redirect("\\新建 公文包\\Default.aspx");
Response.End();
}
protected void GridView1_SelectedIndexChanged1(object sender, EventArgs e)
{
}
}
string id = GridView1.DataKeys[e.RowIndex].Values[0].ToString();被指出如标题所示问题,应该怎么改呢? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询