错误:(使用 ASP.NET/C# 的 Microsoft Visual Studio):
子查询返回超过 1 个值。当子查询跟随 =、!=、<、<=、>、>= 或子查询用作表达式时,这是不允许的。
更多细节:前面的错误是由以下代码引起的。它是一个 GridView 和关联的 SQLDataSource。
<asp:GridView ID="gGrid" runat="server" AutoGenerateColumns="False"
DataSourceID="sqlAll" AllowPaging="True"
onpageindexchanging="grdGrid_PageIndexChanging">
<Columns>
<asp:BoundField DataField="A" HeaderText="A"
SortExpression="A" />
<asp:BoundField DataField="G" HeaderText="G"
SortExpression="PeriodCode" />
<asp:BoundField DataField="Value" HeaderText="Value" SortExpression="Value" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="sqlAll" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionDB01 %>"
SelectCommand="SELECT [A], [G], [H] FROM [Table1]
WHERE [B] =
(SELECT [B]
FROM [Table2]
WHERE [C] = @C)
AND ([D] =
(SELECT [D]
FROM [Table3]
WHERE [E] = @E))
AND ([A] < @A) AND ([A] > @A2)">
<SelectParameters>
<asp:ControlParameter ControlID="ddlBlah2" Name="AreaName"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="ddlBlah" Name="B"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="txtEndA" Name="A"
PropertyName="Text" Type="Decimal" />
<asp:ControlParameter ControlID="txtStartA" Name="A2"
PropertyName="Text" Type="Decimal" />
</SelectParameters>
</asp:SqlDataSource>
<br />
(@Letter 表示它们来自下拉列表参考。)
点评:很明显,代码中有子查询。但是,如何解决非子查询限制?:( 这些事情通常是如何处理的?