"System.IndexOutOfRangeException: 在位置 0 处没有任何行"错误!怎么改啊
我的数据库中有数据但总出现dr = ds.Tables["entermx"].Rows[0];一行有错,不知怎么修改。我是从一个页面的DataGrid中一个链接列实现的一个链接页public class entergoodsmx : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
public String entergoodsid;
public DataRow dr;
private void Page_Load(object sender, System.EventArgs e)
{
//取得上个页面传递来的参数值
entergoodsid = Request.Params["entergoodsid"];
SqlConnection sqlcon = new SqlConnection("server=.;uid=sa;pwd=;database=peisong");
//sqlcon.Open;
string entermx="select * from entermx where entergoodsid =" + Convert.ToInt32(entergoodsid);
SqlDataAdapter MyCommandnews = new SqlDataAdapter(entermx,sqlcon);
DataSet ds = new DataSet ();
MyCommandnews.Fill(ds,"entermx");
dr = ds.Tables["entermx"].Rows[0];
}
}