是否可以按LastActivityDate
的顺序显示此数据<asp:AccessDataSource ID="usage_info_DS" runat="server" DataFile="~/App_Data/ASPNetDB.mdb" SelectCommand="SELECT aspnet_Users.UserName, aspnet_Users.LastActivityDate, aspnet_Membership.LastLoginDate FROM (aspnet_Membership INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId) WHERE (aspnet_Membership.UserId <> 100) AND (aspnet_Membership.UserId IN (SELECT UserId FROM aspnet_UsersInRoles WHERE (RoleId = (SELECT RoleId FROM aspnet_Roles WHERE (RoleName = ?)))))">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:AccessDataSource>
干杯 罗斯
答案 0 :(得分:0)
试
<asp:AccessDataSource ID="usage_info_DS" runat="server" DataFile="~/App_Data/ASPNetDB.mdb" SelectCommand="SELECT aspnet_Users.UserName, aspnet_Users.LastActivityDate, aspnet_Membership.LastLoginDate FROM (aspnet_Membership INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId) WHERE (aspnet_Membership.UserId <> 100) AND (aspnet_Membership.UserId IN (SELECT UserId FROM aspnet_UsersInRoles WHERE (RoleId = (SELECT RoleId FROM aspnet_Roles WHERE (RoleName = ?))))) order by aspnet_Users.LastActivityDate">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="?" PropertyName="SelectedValue" />
</SelectParameters>
</asp:AccessDataSource>
答案 1 :(得分:0)
在sql语句中使用order by clause。所以你的查询应该是:
SELECT
aspnet_Users.UserName,
aspnet_Users.LastActivityDate,
aspnet_Membership.LastLoginDate
FROM
(aspnet_Membership INNER JOIN aspnet_Users ON aspnet_Membership.UserId = aspnet_Users.UserId)
WHERE
(aspnet_Membership.UserId <> 100)
AND (aspnet_Membership.UserId IN (SELECT UserId FROM aspnet_UsersInRoles
WHERE (RoleId = (SELECT RoleId FROM aspnet_Roles WHERE (RoleName = ?)))))
order by 2;
2指定要应用order by的列,您也可以使用列名aspnet_Users.LastActivityDate
修改强>
如果您想在结果集的顶部获取最新日期,请使用:
order by 2 desc;