第3个SelectParameter在SQL语句中无法识别的问题:[UsersDataTbl.UID] NOT IN (SELECT UID FROM [EnrollmentsTbl] WHERE ClassName = ?) AND Completed = True
我也使用了@ClassName
并得到了同样的错误:"没有给出一个或多个必需参数的值。 "
如果我更换?使用'实际的班级名称',结果符合要求。
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
DataSourceID="AccessDataSource2" DataTextField="ClassName" DataValueField="ClassName">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList3" runat="server"
DataSourceID="AccessDataSource4" DataTextField="Battallion"
DataValueField="Battallion" AutoPostBack="True">
</asp:DropDownList>
<asp:DropDownList ID="DropDownList4" runat="server"
DataSourceID="AccessDataSource5" DataTextField="Shift"
DataValueField="Shift" AutoPostBack="True">
</asp:DropDownList>
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="<%$ ConnectionStrings:AccessSubSiteString %>"
SelectCommand="SELECT [UsersDataTbl.StudentID], [UsersDataTbl.UserName],
[UsersDataTbl.LastName], [UsersDataTbl.FirstName], [UsersDataTbl.Affiliation], [UsersDataCareerTbl.Battallion], [UsersDataCareerTbl.Shift], [UsersDataTbl.UID], [ALSProviders.ALS]
FROM ([UsersDataTbl] INNER JOIN [UsersDataCareerTbl] ON (UsersDataTbl.UID = UsersDataCareerTbl.UID)) LEFT JOIN [ALSProviders] ON (UsersDataTbl.UID = ALSProviders.UID)
WHERE [UsersDataTbl.Career] = True AND [UsersDataTbl.Active] = True AND (UsersDataCareerTbl.Battallion = ?) AND (UsersDataCareerTbl.Shift = ?)
AND ([UsersDataTbl.UID] NOT IN (SELECT UID FROM [EnrollmentsTbl] WHERE ClassName = ?) AND Completed = True)
ORDER BY [UsersDataTbl.LastName]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList3" Name="Battallion" PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="DropDownList4" Name="Shift" PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="DropDownList1" Name="ClassName" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:AccessDataSource>
答案 0 :(得分:0)
感谢@Rafael的指导,添加额外的JOIN似乎解决了这个问题。仍然需要IS NULL
。这是决议:
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="<%$ ConnectionStrings:AccessSubSiteString %>"
SelectCommand="SELECT [UsersDataTbl.StudentID], [UsersDataTbl.UserName], [UsersDataTbl.LastName], [UsersDataTbl.FirstName], [UsersDataTbl.Affiliation], [UsersDataCareerTbl.Battallion], [UsersDataCareerTbl.Shift], [UsersDataTbl.UID], [ALSProviders.ALS]
FROM (([UsersDataTbl] INNER JOIN [UsersDataCareerTbl] ON (UsersDataTbl.UID = UsersDataCareerTbl.UID))
LEFT JOIN [ALSProviders] ON (UsersDataTbl.UID = ALSProviders.UID))
LEFT JOIN [EnrollmentsTbl] ON (UsersDataTbl.UID = EnrollmentsTbl.UID AND ClassName = ?)
WHERE [UsersDataCareerTbl.Battallion] = ?
AND [UsersDataCareerTbl.Shift] = ?
AND [EnrollmentsTbl.UID] IS NULL
ORDER BY [UsersDataTbl.LastName]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList3" Name="Battallion" PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="DropDownList4" Name="Shift" PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="DropDownList1" Name="ClassName" PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:AccessDataSource>