我如何获得具有值的学生列表。我无法在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;
答案 0 :(得分:0)
您可以使用DBNUll.Value
代替Null
foreach (DataRow row in dt.Rows)
{
if (row["address"]!=DBNull.Value)
// line above is not ab
{ retVal.Add((string)row["student"]); }
}