I'm setting up a very basic login screen I need help with... SQL Server backend table, VB.net script. I need to know the basics of the VB.net code and how I need to reword my SqlDataSource to handle the matching of the two variables. Thanks! Here's where
I'm at so far:
What do you mean by 'validation that the user's name and PW match'? Do you mean that they match what you have in the database? That this is a valid user? Isn't that why you are doing this select?
I'm scripting the code rather than using code behind. I was just wondering if the handler for the button needs to reference the SqlDataSource's select.
I don't really know anything about scripting but using regular .aspx and code behind, you would need to call SqlDataSource.Select() but don't need to pass in the parameters (because they are already declared on the .aspx page). I don't know what this would
translate to when using scripts.
Maybe try to run in and see what happens. If you get an error, post it.
Protected Sub btnLogIn_Click(sender As Object, e As System.EventArgs)
SqlDataSource1.Select()
Server.Transfer("MainMenu.aspx")
End Sub
The "SqlDataSource1.Select()" gives a jagged underline with: "Argument not specified for parameter 'arguments of 'Public Function Select
(arguments As Sytem.Web.UI.DataSource Select Arguments) As System.Collections.IEnumerable'.
Seems you need to add this line - DataSourceSelectArguments arguments = new DataSourceSelectArguments();
and then SqlDataSource1.Select(arguments)
Another suggestion was to bind the data instead or .Select() but I don't think that would work for you since you are not binding the data to anything - you are simply checking that the user exists in the db.
Eugene1968
Member
90 Points
360 Posts
simple login form
Jan 08, 2013 01:58 PM|LINK
I'm setting up a very basic login screen I need help with... SQL Server backend table, VB.net script. I need to know the basics of the VB.net code and how I need to reword my SqlDataSource to handle the matching of the two variables. Thanks! Here's where I'm at so far:
<asp:SqlDataSource
ID="SqlDataSource1"
runat="server"
connectionstring="<%$ ConnectionStrings:TrackITConnectionString %>"
selectcommand="SELECT * [UserName], [Password] FROM [tblUsers]">
</asp:SqlDataSource>
<asp:TextBox ID="UserID" runat="server"></asp:TextBox>
<asp:TextBox ID="txtPW" runat="server"></asp:TextBox>
<asp:Button ID="btnLogIn" runat="server" Text="Log In" onclick="btnLogIn_Click"/>
msmk
Participant
776 Points
159 Posts
Re: simple login form
Jan 08, 2013 02:27 PM|LINK
Add to the SqlDataSource:
<SelectParameters>
<asp:ControlParameter ControlID="UserID" Name="UserName"
PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="txtPW" Name="Password"
PropertyName="Text" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
Eugene1968
Member
90 Points
360 Posts
Re: simple login form
Jan 08, 2013 02:36 PM|LINK
Do I need any vb.net code to handle the validation that the user's name and PW match when the button is pressed?
msmk
Participant
776 Points
159 Posts
Re: simple login form
Jan 08, 2013 02:39 PM|LINK
What do you mean by 'validation that the user's name and PW match'? Do you mean that they match what you have in the database? That this is a valid user? Isn't that why you are doing this select?
Eugene1968
Member
90 Points
360 Posts
Re: simple login form
Jan 08, 2013 02:49 PM|LINK
What I mean is when I call the SqlDataSource1.Select do I pass in any parameters?
Protected Sub Button1_Click(sender As Object, e As System.EventArgs)
SqlDataSource1.Select()
Server.Transfer("MainMenu.aspx")
End Sub
msmk
Participant
776 Points
159 Posts
Re: simple login form
Jan 08, 2013 02:55 PM|LINK
No. You declared the parameters on the .aspx page so no need to pass them again in the code behind.
Eugene1968
Member
90 Points
360 Posts
Re: simple login form
Jan 08, 2013 03:29 PM|LINK
I'm scripting the code rather than using code behind. I was just wondering if the handler for the button needs to reference the SqlDataSource's select.
msmk
Participant
776 Points
159 Posts
Re: simple login form
Jan 08, 2013 04:04 PM|LINK
I don't really know anything about scripting but using regular .aspx and code behind, you would need to call SqlDataSource.Select() but don't need to pass in the parameters (because they are already declared on the .aspx page). I don't know what this would translate to when using scripts.
Maybe try to run in and see what happens. If you get an error, post it.
Eugene1968
Member
90 Points
360 Posts
Re: simple login form
Jan 08, 2013 05:06 PM|LINK
Protected Sub btnLogIn_Click(sender As Object, e As System.EventArgs)
SqlDataSource1.Select()
Server.Transfer("MainMenu.aspx")
End Sub
The "SqlDataSource1.Select()" gives a jagged underline with: "Argument not specified for parameter 'arguments of 'Public Function Select
(arguments As Sytem.Web.UI.DataSource Select Arguments) As System.Collections.IEnumerable'.
msmk
Participant
776 Points
159 Posts
Re: simple login form
Jan 08, 2013 05:19 PM|LINK
Did a google search on this error and came up with this: http://forums.asp.net/t/1091241.aspx
Seems you need to add this line - DataSourceSelectArguments arguments = new DataSourceSelectArguments();
and then SqlDataSource1.Select(arguments)
Another suggestion was to bind the data instead or .Select() but I don't think that would work for you since you are not binding the data to anything - you are simply checking that the user exists in the db.