...

View Full Version : Problems i have regarding database connection with login



Coldflame
03-23-2011, 01:45 PM
Hello,

this is my first time posting. and just so you know i'm an ASP.NET noob :)
this year i got a project in school and it suposed to be made in asp.net thus thats why i'm learing. i'll provide you with as much info as i can

anyway, the "idea" is to make an evaluation site that has a members that can login, and an admin + sub admin. all of this has to be connected with a database ( ofc :p ).

now the place where i am stuck, or that i experiance problems is this:
i have my database and my database connection. i can already write in the database because i made the "register users".
However. i just cant seem to fix my Login :(
i dont know how to get the values that you write into the texboxes on the site and then "accept" these and and get those out of the database.
eg: i type Test1 (as username) and qwerty1 (as password).
lets say this exists in my database. how can i check that and actuallly log in ?

i have my Login.aspx that has this:



<asp:Login ID="LoginUser" runat="server" EnableViewState="false" RenderOuterTable="false">
<LayoutTemplate>
<span class="failureNotification">
<asp:Literal ID="FailureText" runat="server"></asp:Literal>
</span>
<asp:ValidationSummary ID="LoginUserValidationSummary" runat="server" CssClass="failureNotification"
ValidationGroup="LoginUserValidationGroup"/>
<div class="accountInfo">
<fieldset class="login">
<legend>Account Informatie</legend>
<p>
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">Gebruikersnaam:</asp:Label>
<asp:TextBox ID="UserName" runat="server" CssClass="textEntry"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
CssClass="failureNotification" ErrorMessage="Gebruikersnaam is vereist." ToolTip="Gebruikersnaam is vereist."
ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">Passwoord:</asp:Label>
<asp:TextBox ID="Password" runat="server" CssClass="passwordEntry" TextMode="Password"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
CssClass="failureNotification" ErrorMessage="Passwoord is vereist." ToolTip="Passwoord is vereist."
ValidationGroup="LoginUserValidationGroup">*</asp:RequiredFieldValidator>
</p>
<p>
<asp:CheckBox ID="RememberMe" runat="server" Visible="false" />
<asp:Label ID="RememberMeLabel" runat="server" AssociatedControlID="RememberMe" CssClass="inline" Visible="false">Keep me logged in</asp:Label>
</p>
</fieldset>
<p class="submitButton">
<asp:Button ID="LoginButton" runat="server" CommandName="Login" Text="Log In" ValidationGroup="LoginUserValidationGroup" onclick="btnAanmelden_Click"/>
</p>
</div>
</LayoutTemplate>
</asp:Login>


+ the C# file



public partial class Login : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd;

protected void Page_Load(object sender, EventArgs e)
{
RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]);

string connstring = ConfigurationManager.ConnectionStrings["ConnectionTest"].ConnectionString;
con = new SqlConnection(connstring);
}
protected void btnAanmelden_Click(object sender, EventArgs e)
{

try {
con.Open();
cmd = new SqlCommand("Select (pasworod,gebruikers_naam) from Gebruiker where gebruiker_naam= values('"+ Username + "'", con);
}
catch (Exception)
{throw;}


}
public bool UserName{get;set;}
}


any help would be very appreciated :) i've been stuck at this for serveral days now.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum