我正在制作一个报表工具,它具有一个aspx网页,可以从SQL表中读取数据并将该数据插入到标签的文本中。到目前为止,这很容易。我的问题是,如何可以读取的数据的多行从表到单个asp.Label如何从一个表中读取多行数据到一个单一的asp.Label
例如,
印象:ROW1; Row2:Row3; ROW4; ROW5。
SQL查询
SELECT a.Value
From ImpressionEcho a
Inner join PatientData p on a.P_ID p.P_ID where p.P_ID = 1
给出了这样的数据
Mildly dilated aortic root
Moderately dilated aortic root
Possible dissection
Mild mitral regurgitation
Reduced LV diastolic compliance
No significant valvular abnormalities
ASPX供读者
<Table>
<tr>
<td colspan="2">
<asp:Label ID="Aorta" runat="server" Text="Impression:" ForeColor="Black" Font-Underline="true"></asp:Label>
</td>
<td>
<asp:Label ID="ImpressionReader" runat="server" Text="AortaReader" ForeColor="Black" ></asp:Label>
</td>
</tr>
</Table>
C#代码的代码来调用读者
ImpressionReader.Text = reader["Value"].ToString();
我一直在四处搜寻,还没有找到任何具体的问题,所以如果任何人都可以帮助或指出我在正确的方向,它是不胜感激。
UPDATE
礼的回答指出我对于那些在未来这个寻找答案,这个正确的方向是SQL查询中使用
SELECT DISTINCT
STUFF((SELECT '; ' + Value
FROM ImpressionEcho data1
FOR XML PATH('')), 1, 1, '') [Impression]
FROM ImpressionEcho data
这给了我
Mildly dilated aortic root; Moderately dilated aortic root; Possible dissection; Mild mitral regurgitation; Reduced LV diastolic compliance; No significant valvular abnormalities
然后我可以从我的C#阅读器读取[“印象”]
你能告诉你的代码! –
@ S.Akbari编辑 – NMatheny