日期:2014-05-18  浏览次数:20831 次

用数组记录数据库的值
现有一数据库表test字段有a,b,c   现在想用一数组来记录test表中的数据,也就是把test表中的数据复制到一个数组中去     用C#语言描述数据库是用SQL2000     还望大虾们帮帮忙

------解决方案--------------------
up
------解决方案--------------------
public ArrayList GetPositionIDByOut(int startPoint, int endPoint)
{
ArrayList list = new ArrayList();
String v_sql = "select top " + startPoint + " PositionID from result_particular_t where PositionID not in(select top " + endPoint + " PositionID from result_particular_t) order by PositionID desc; ";
SqlDataReader dr = ExecuteReader(v_sql);
while (dr.Read())
{
list.Add(dr[ "positionID "]);
}
dr.Close();
return list;
}
------解决方案--------------------
string sqlstr = "select a,b,c from yourtable ";
da = new SqlDataAdapter(sqlstr, conn);
ds = new DataSet();
da.Fill(ds);
string[,] dsArr = new string[ds.Tables[0].Rows.Count,3];
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
dsArr[i,0]= ds.Tables[0].Rows[i][0].ToString();
dsArr[i,1]= ds.Tables[0].Rows[i][1].ToString();
dsArr[i, 2] = ds.Tables[0].Rows[i][2].ToString();
}