怎样才能把DataRow的数据保存到,这几个一维数组中???
找不到资料,请教一个DataRow的问题
DataSet ds = new DataSet();
this.adapter.Fill(ds);
foreach(DataTable dt in ds.Tables)
foreach(DataRow row in dt.Rows){
this.FirstName[0] = Convert.ToString(row[ "FirstName "]);
this.LastName[0] = Convert.ToString(row[ "LastName "]);
this.Bats[0] = Convert.ToChar(row[ "Bats "]);
this.AB[0] = Convert.ToInt32(row[ "AB "]);
}
怎样才能把DataRow的数据保存到,这几个一维数组中???
------解决方案--------------------DataSet ds = new DataSet();
this.adapter.Fill(ds);
foreach(DataTable dt in ds.Tables)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
DataRow dr = dt.Rows[i];
this.FirstName[i] = Convert.ToString(dr[ "FirstName "]);
this.LastName[i] = Convert.ToString(dr[ "LastName "]);
this.Bats[i] = Convert.ToChar(dr[ "Bats "]);
this.AB[i] = Convert.ToInt32(dr[ "AB "]);
}
}