0

我有一部分代码,它返回非不同的值。

无论如何,我可以使用不同的函数来获得不同的值吗?

代码:

public static Recordset queryTestDirector(string projectName, string query)
  {
     Recordset result = null;
     /*Connect to Test director and pull down all the currently listed QC numbers*/
     TDConnection tdConnection;
     tdConnection = new TDAPIOLELib.TDConnection();
     tdConnection.InitConnection("http://***/qcbin/", "ABC", "");
     tdConnection.ConnectProject(projectName, "qc_manager", "");

     Command cmd;
     cmd = tdConnection.Command as Command;
     String qcIDQuery = query;
     cmd.CommandText = qcIDQuery;
     result = cmd.Execute() as Recordset;

     tdConnection.Disconnect();
     return result;

  }

问题是返回的结果给出了值:A,A,A,A,B,C,D

我只想要A,B,C,D

请建议。

4

3 回答 3

0

没试过,但这可能有效。您首先必须将记录集转换为数据集

ds.Tables[0].DefaultView.ToTable(true,"BG_USER_50");

这是一个解释更多的链接

http://www.c-sharpcorner.com/blogs/230/how-to-get-disticnt-rows-from-a-dataset-or-datatable.aspx

如何在数据表中选择不同的行并存储到数组中

于 2012-08-31T06:50:16.717 回答
0

非常感谢您的输入,这让我重新考虑了查询。

最后这个查询有效:

queryString = "select BG_USER_50, count(*) from BUG where BG_STATUS in ('In Progress','Fixed','Unit Testing','Ready For UAT') and BG_USER_50 is not null group by BG_USER_50 order by 1 desc"

我只需要一个 Group by 子句。

于 2012-08-31T07:09:34.090 回答
0

将您的查询更改为

select distinct BG_USER_50 from BUG where BG_STATUS in ('In Progress','Fixed','Unit Testing','Ready For UAT') and BG_USER_50 is not null order by BG_BUG_ID desc

应该解决你的问题

于 2012-08-31T06:14:23.110 回答