我制作了一个登录页面来验证用户。我有一个如下的 sql 表:
表:tblUsers
userID (int is identity)
username (nvarchr (50))
password (nvarchr (50))
登录.ASPX
Username<asp:TextBox ID="txtUsername" runat="server"></asp:TextBox><br />
Password <asp:TextBox ID="txtPassword" runat="server"></asp:TextBox><br />
<asp:Button ID="cmdLogin" runat="server" Text="Login"
onclick="cmdLogin_Click" /><br />
<asp:Label ID="lblError" runat="server" EnableViewState="False"></asp:Label><br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConStr %>"
SelectCommand="SELECT * FROM [tblUser] WHERE (([username] = @username) AND ([password] = @password))">
<SelectParameters>
<asp:ControlParameter ControlID="txtPassword" Name="username"
PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="txtPassword" Name="password"
PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
验证用户在 SqlDataSource 的 SelectCommand 中。
SELECT * FROM [tblUser] WHERE (([username] = @username) AND ([password] = @password))
如何通过 SqlDataSource 验证用户?我想要登录按钮的代码。