在你的存储过程的最后的 end 之前,执行
select A(字段),B(字段),C(字段),D(字段) from 表名 where ....那么,调用存储过程时,
yourAdapter.SelectCommand.ExecuteNonQuery();
yourAdapter.Fill( dataTable );则dataTable中的
(int) dataTable.Rows[0]["A(字段)"] ;//就是A的值
....//其它同理
select A(字段),B(字段),C(字段),D(字段) from 表名 where ....那么,调用存储过程时,
yourAdapter.SelectCommand.ExecuteNonQuery();
yourAdapter.Fill( dataTable );则dataTable中的
(int) dataTable.Rows[0]["A(字段)"] ;//就是A的值
....//其它同理
for(int i=0;i<anumbet;i++)
{
for(int j=0;j<3;j++)
score[j]=(int)dataTable.Rows[i]["j"];
}
这里的j能代表A,B,C,D字段吗我想能,在有的细节上我还是昏的,基础把扎实谢谢各位回答
{
for(int j=0;j<3;j++)
score[j]=(int)dataTable.Rows[i]["j"];
}
===========================Rows[i]----->i表示第i行,因为,查询的结果集通常有多条,你这个问题中我认为只有一行,故直接取Row[0]Rows[i]["A(字段)"] ----->表示第i行的字段名为“A(字段)”的值,当然也可以写出你所写的那样,但是需要改一下
score[j]=(int)dataTable.Rows[i]["j"];
---->
score[j]=(int)dataTable.Rows[i][j];
for(int i=0;i<scoreTable.Rows.Count;i++){
for(int j=0;j<4;j++){
scores[i,j]=(int)scoreTable.Rows[i][j];
}
}