Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 09, 2013 06:17 PM by msmk
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:
connectionstring="<%$ ConnectionStrings:TrackITConnectionString %>"
selectcommand="SELECT * [UserName], [Password] FROM [tblUsers]">
<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"/>
Jan 08, 2013 02:27 PM|LINK
Add to the SqlDataSource:
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?
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?
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)
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.
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.
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.
Jan 08, 2013 05:06 PM|LINK
Protected Sub btnLogIn_Click(sender As Object, e As System.EventArgs)
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'.
Jan 08, 2013 05:19 PM|LINK
Did a google search on this error and came up with this:
Seems you need to add this line - DataSourceSelectArguments arguments = new
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.