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 8419661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:40:31+00:00 2026-06-10T02:40:31+00:00

I have to catch the username entered in the login page and get corresponding

  • 0

I have to catch the username entered in the login page and get corresponding profileid(the column in DB) and show it in another page my DAL code is

public DataTable getall()
   {
       SqlConnection conn1 = Generic.DBConnection.OpenConnection();
       DataTable dt=new DataTable();
       try
       {
             string sql = "Select * from Profile_Master";
             SqlCommand cmds = new SqlCommand(sql,conn1);
             SqlDataAdapter sqlDa = new SqlDataAdapter(cmds);
           sqlDa.Fill(dt);


       }
       catch (Exception ex)
       {

           throw ex;
       }
       return dt;
   }

My UI

DataTable dt1 = new DataTable();
                ProfileMasterDAL dal = new ProfileMasterDAL();
                dt1 = dal.getall();
                if (dt1.Rows.Count > 0)
                {
                    Session["sdds"] = dt1.Rows[0]["FirstName"].ToString();
                    Session["EmailId"] = dt1.Rows[0]["EmailID"].ToString();
                    Session["pid"] = dt1.Rows[0]["NewidColumn"].ToString();
                    Response.Redirect("~/Myhome.aspx");

but i am able to get the first value in the DB not the corresponding value for the username?

  • 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-10T02:40:32+00:00Added an answer on June 10, 2026 at 2:40 am

    Your select statement has 10 rows. and the required row for you is in 5th position.
    when you say dt1.Rows[0][“FirstName”] you will get only the first record but not the 5th record.

    If you want to make this work, add where condition to your select statement, which returns exactly one required row for you.

    something like..

    “select * from Profile_Master PM Where PM.UserName = @username”

    where @username is your input from login page. And is unique in the database Table

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this piece of code: try { System.out.println(????????????????????????????????); request.login(username, password); System.out.println(FFFFFFFFFFFFFFFF); } catch
I have the following code: [WebMethod] [SoapHeader(_webServiceAuth)] public User GetUser(string username) { try {
So I have this username and password validation code using Java persistence. public Subscriber
Please have a look the following code public String setEmailAccount(String account,String userName, String password)
How can I get the username/login name in Java? This is the code I
i have one login.jsp web page where i have two textboxes for username and
In my Java code, I occasionally run into situations where I have to catch
I have a Try Catch in my code. I would like to know if
I have never used Try-catch in my code before, but now I need to
Hy i have the following code : import java.sql.*; import java.net.*; public class binsz

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.