如何获取其中包含值的学生列表。我不能写select查询来检索,实际上对于数据集,我将调用返回所有学生的方法
public IEnumerable GetCallingCodes()
{
DataSet ds = DataOps.GetDataSet(string.Format(" select * from students"));
// foreach
DataTable dt = ds.Tables[0];
List<string> retVal = new List<string>();
foreach (DataRow row in dt.Rows)
{
if (row["address"]!=null)
// line above is not ab
{ retVal.Add((string)row["student"]); }
}
return retVal;发布于 2011-05-04 13:22:31
您可以使用DBNUll.Value而不是Null
foreach (DataRow row in dt.Rows)
{
if (row["address"]!=DBNull.Value)
// line above is not ab
{ retVal.Add((string)row["student"]); }
}https://stackoverflow.com/questions/5878870
复制相似问题