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

  • SEARCH
  • Home
  • 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 677591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:03:23+00:00 2026-05-14T01:03:23+00:00

protected static Boolean Authentication(string username, string password) { string sqlstring; sqlstring = Select Username,

  • 0
protected static Boolean Authentication(string username, string password)
{
    string sqlstring;
    sqlstring = "Select Username, Password, UserType from Userprofile WHERE Username='" + username + "' and Password ='" + password + "'";

    // create a connection with sqldatabase 
    System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection(
                 "Data Source=PRADEEP-LAPTOP\\SQLEXPRESS;Initial Catalog=BookStore;Integrated Security=True");

    // create a sql command which will user connection string and your select statement string
    System.Data.SqlClient.SqlCommand comm = new System.Data.SqlClient.SqlCommand(sqlstring, con);

    // create a sqldatabase reader which will execute the above command to get the values from sqldatabase
    System.Data.SqlClient.SqlDataReader reader;

    // open a connection with sqldatabase
    con.Open();

    // execute sql command and store a return values in reade
    reader = comm.ExecuteReader();

    // check if reader hase any value then return true otherwise return false
    if (reader.Read())
        return true;
    else
        return false;
}

Boolean blnresult;

blnresult = Authentication(Login2.UserName, Login2.Password);

if (blnresult == true)
{
    Session["User_ID"] = getIDFromName(Login2.UserName);
    Session["Check"] = true;
    Session["Username"] = Login2.UserName;

    Response.Redirect("Index.aspx");
}

so a user like Staff or even Administrators loging to same Index.aspx. i want to change it to different web pages.

how to change sites for each user types. i have seperate user types. and i have taken UserType in the Authentication function.

  • 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-05-14T01:03:23+00:00Added an answer on May 14, 2026 at 1:03 am

    Why don’t you make your authentication method return a string? It can return the user type when a user is authenticated, and it can return empty or null when authentication fails. Then you can just say

    string userType = Authentication(Login2.UserName, Login2.Password);
    if(userType != string.IsNullOrEmpty)
    {
      if(userType.Equals("yourType")
        Response.Redirect("firstSite.aspx");
      elseif //...etc
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a native function for protected static native boolean _connect(String user,
i have script for insert multiple rows : protected static final String INSERT_NAME_LIST1 =
I have this code fragment: public static class ExportDatabaseFileTask extends AsyncTask<String, Void, Boolean> {
I have the following class: class risc { // singleton protected: static unsigned long
So i got a class like this: class Db { protected static $dbh =
I neet access to current object in a static method. Code: protected static $name;
class ConfigReader { private static $instance = NULL; protected $configData = array(); public function
We need to protect a class from having static methods for security purposes. We
I have created a static method to display a popup on my website from
I'm trying to query the sharepoint search with the following code protected ResultTable Search(String

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.