Go Back   CodingForums.com > :: Server side development > ASP.NET

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-23-2011, 01:45 PM   PM User | #1
Coldflame
New to the CF scene

 
Join Date: Mar 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Coldflame is an unknown quantity at this point
Unhappy Problems i have regarding database connection with login

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 ).

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:

Code:
<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

Code:
  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.
Coldflame is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:12 PM.


Advertisement
Log in to turn off these ads.