Hi guys,
I have problem with my login script. I am using VB.Net (ASP.Net) to do that things.
Here is the code:
This is the code for Default.aspx page
User Name: <asp:TextBox ID="userID" class="txtbox" runat="server"></asp:TextBox>
Password: <asp:TextBox ID="password" class="pwdbox" runat="server" TextMode="Password"></asp:TextBox>
<asp:LinkButton ID="login" class="button" runat="server"> Login </asp:LinkButton>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:mcisaaConnectionString1 %>" ProviderName="<%$ConnectionStrings:mcisaaConnectionString1.ProviderName %>" SelectCommand="SELECT [UsrName], [Pass], [UsrStatus] FROM [UsrLoginInfo] WHERE (([UsrName] = @UsrName) AND ([Pass] = @Pass))">
<SelectParameters>
<asp:ControlParameter ControlID="userID" Name="UsrName" PropertyName="Text" Type="String"/>
<asp:ControlParameter ControlID="password" Name="Pass" PropertyName="Text" Type="String"/>
</SelectParameters>
</asp:SqlDataSource>
This is the code for Default.aspx.vb
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub login_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles login.Click
Dim xReader As Data.IDataReader = SqlDataSource1.Select(DataSourceSelectArguments.Empty)
If xReader.Read Then
Session("SessionStart") = "True"
Session("UserID") = userID.Text
Session("UserName") = xReader.Item("UsrName")
Session("UserStatus") = xReader.Item("UsrStatus")
End If
End Sub
End Class
And I have no change for the web.config file.
While I am executed the page, and clicking login button, always show the error: Unable to cast object of type 'System.Data.DataView' to type 'System.Data.IDataReader'.
What's wrong with the code? I have try to finding solution on the internet but it was the same.
Thanks.