Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8287521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:04:24+00:00 2026-06-08T12:04:24+00:00

I have login in my asp page req name/pass and button. I create the

  • 0

I have login in my asp page req name/pass and button.

I create the connecttion string to my database and SqlDataSource with the query well here in the SqlDataSource:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
     ConnectionString="<%$ ConnectionStrings:CarRentalConnectionString %>" 
     SelectCommand="SELECT * FROM [Customers] WHERE (([UserName] = @UserName) AND ([PassWord] = @PassWord))">
     <SelectParameters>
        <asp:ControlParameter ControlID="uname" Name="UserName" PropertyName="Text" Type="String" />
        <asp:ControlParameter ControlID="pass" Name="PassWord" PropertyName="Text" Type="String" />
    </SelectParameters>
</asp:SqlDataSource>

My problem is I don’t know how to active/execute it and how do I get the data that is returned from the query?

I have a feeling am going at this the wrong way (hope am wrong)

Hope one of you can give me a tip or point me in the right direction 🙂

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:04:27+00:00Added an answer on June 8, 2026 at 12:04 pm

    Using SqlDataSource is inappropriate as you’re not simply retrieving data in a declaritive way. You’ll want to define user verification (not validation) logic procedurally.

    The usual approach follows. Note that you should hash your passwords rather than storing them in plaintext. Hash salting has been omited for brevity.

    public static Boolean Authenticate(String userName, String password) {
    
        using(SqlConnection c = new SqlConnection("myConnectionString")
        using(SqlCommand cmd = c.CreateCommand()) {
            c.Open();
            cmd.CommandText = "SELECT UserName, PasswordHash, OtherDataEtc FROM Users WHERE UserName = @userName";
    
            cmd.Parameters.Add("@userName", SqlDbType.Varchar, 50).Value = userEnteredUserName;
    
            using(SqlDataReader rdr = cmd.ExecuteReader()) {
                if( !rdr.Read() ) return false; // no matching user found
    
                Byte[] passwordHash = rdr.GetBytes( 1 );
                Byte[] hash = Hash( userEnteredPassword ); // Use at least SHA1
                return Array.Equals( passwordHash, hash );
            }
        }
    }
    
    // Usage in ASP.NET:
    
    public override OnPageLoad(Object sender, EventArgs e) {
        if( IsPostBack ) {
            Validate();
            if( IsValid ) {
                Boolean auth = Authenticate( this.userName, this.password ); // member textbox controls
                if( auth ) {
                    FormsAuthentication.SetAuthCookie( this.userName, true );
                    FormsAuthentication.RedirectFromLoginPage("somewhere", true);
                } else {
                    Response.Redirect("loginFailedPage");
                }
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple ASP.Net login page. When the login button is clicked, the
I have created a simple login page for asp.net which takes in user name
In my page I have a login control: <asp:Login ID=EMSLogin runat=server OnAuthenticate=EMSLogin_Authenticate> <LayoutTemplate> <asp:Panel
I have a login page written in classic asp. I want to set the
I'm using ASP.NET MVC 2 and have a login page that is secured via
I have an ASP.NET login control on a page, with the Remember Me checkbox
I have an ASP.NET home page where user provides his login ID. Depending on
I have an ASP.Net website which has a remember me feature for Login page.
I have a simple, single-page in ASP.NET (C#). I wanted to add login control,
I'm new to web development. I have a login.aspx page that has an Asp.Net

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.