【发布时间】:2014-01-17 11:45:12
【问题描述】:
我有这样的列表方法 testing 是有theree的类
public ArrayList converttolist(string commandText, CommandType commandType)
{
ArrayList Listlines = new ArrayList();
SqlCommand cmd = new SqlCommand();
cmd.CommandText = commandText;
cmd.CommandType = commandType;
cmd.Connection = obj_con.getconection();
try
{
cmd.Connection.Open();
using (SqlDataReader sdr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
testing ts = new testing();
var alldata = new state_testingCLS.testing();
while (sdr.Read())
{
ts.id_11 = Convert.ToInt64(sdr["id_11"]);
ts.countryid = Convert.ToInt64(sdr["countryid"]);
ts.state = Convert.ToString(sdr["state"]);
Listlines.Add((ts));
}
sdr.Close();
}
return Listlines;
}
catch (Exception ex)
{
throw ex;
}
finally
{
cmd.Connection.Close();
cmd.Dispose();
}
}
在 listlines 中,我必须获取记录,但我对此一无所知,请帮我解决这个问题
现在如果我访问它
ArrayList aa= cls.getAll();
foreach (state_testingCLS.testing Txt in aa)
{
string aa1 = Txt.state.ToString();
}
每次返回相同的数据
【问题讨论】:
-
检查更新的@NitinVarpe
-
我不确定我是否理解您的问题,但您正在插入
alldata但从未在其上设置任何属性。您的意思是插入ts吗? (Listlines.Add(ts)) -
抱歉是我的错误@ClaudioRedi