.net 1-从datatable / dataview获取列的唯一值

时间:2011-05-26 18:28:44

标签: asp.net

我们正在使用.net 1,我知道我们应该切换到更高但不是  在我手里。 我试图显示从存储过程返回的列的unque值放入数据表。列的其余部分需要显示所有值。

我用谷歌搜索,发现下面似乎没有在这个版本中工作 - new DataView(myTable).ToTable(true,new string [] {“channel”});

我们还有其他简单方法吗?我不喜欢使用for循环迭代所有值并放入arraylist。

我的代码如下=

    cmd = New SqlCommand("web_RetrieveClient", conn)
    cmd.CommandType = CommandType.StoredProcedure

    param = cmd.Parameters.Add("@ClientKey", SqlDbType.Int, 4)
    param.Value = lClientKey
    param.Direction = ParameterDirection.Input

    adapter.SelectCommand = cmd![enter image description here][1]
    adapter.Fill(dt)
    conn.Close()

请在图片中查看proc的结果数据。 我需要独特的频道。

感谢您的帮助。 navya

2 个答案:

答案 0 :(得分:0)

使用.NET 1.1,您的选择是有限的。 for循环到数组列表可能是你唯一的选择,因为我不认为DataView可以做DISTINCT。

为什么不能重写存储过程?

答案 1 :(得分:0)

最快的方法是:

  • 复制存储过程
  • 在新的存储过程中,使用选择
  • 中的DISTINCT
  • 调用新存储过程