0

例如,使用以下代码。

SELECT COUNT(1) as 'ClientActive', 

(SELECT COUNT(1) FROM t1 AS t2 WHERE t2.fieldname = 'A') AS TotalA,

(SELECT COUNT(1) FROM t1 AS t2 WHERE t2.fieldname = 'B') AS TotalB,
(SELECT COUNT(1) FROM t1 AS t2 WHERE t2.fieldname = 'C') AS TotalC,
(SELECT COUNT(1) FROM t1 AS t2 WHERE t2.fieldname = 'D') AS TotalD
 FROM t1 WHERE clientstatus='active'

我想要这样的回报:

    lblString1.Text = TotalA;
    lblString2.Text = TotalB;
    etc..

有人可以生成 C# 代码来执行此操作吗?谢谢你。

4

1 回答 1

0

使用 DataSet 然后循环遍历它,或者只获取第一行并将每一行值分配给标签(假设您知道如何填充数据集):

lblString1.Text = row["ClientActive"].toString(); lblString2.Text = row["TotalB"].toString(); etc.
于 2013-10-08T18:54:45.447 回答