HI every1 I mongolian studen so i builing one project but we have problem how can i display the logod user status like he's her id number and spme of the profile help any idea ??? :o :o :o :o :o

Dani AI

Generated

As pointed out, a database is the right place for this. For a concrete, minimal approach for your library system (): keep a Users table and a Borrowings table, then fetch the logged-in user’s profile and their current borrowed-book count in one parameterized query. Store either the username (if you use Forms Authentication) or the numeric UserID in Session at login and use that value on the status page.

Example SQL (SQL Server 2000 compatible):

CREATE TABLE Users (
  UserID INT IDENTITY(1,1) PRIMARY KEY,
  Username NVARCHAR(50) NOT NULL,
  FullName NVARCHAR(100),
  Department NVARCHAR(100)
);

CREATE TABLE Borrowings (
  BorrowID INT IDENTITY(1,1) PRIMARY KEY,
  UserID INT NOT NULL,             -- FK to Users.UserID
  BookID INT NOT NULL,
  BorrowDate DATETIME NOT NULL,
  ReturnDate DATETIME NULL
);

Single query to get profile + current borrowed count:

SELECT u.UserID, u.FullName, u.Department,
       ISNULL(b.CountBorrowed,0) AS BorrowedCount
FROM Users u
LEFT JOIN (
  SELECT UserID, COUNT(*) AS CountBorrowed
  FROM Borrowings
  WHERE ReturnDate IS NULL
  GROUP BY UserID
) b ON u.UserID = b.UserID
WHERE u.Username = @username;

Minimal ASP.NET C# pattern (code-behind) — bind results to labels on the page:

string username = User?.Identity?.Name ?? (string)Session["Username"];
if (string.IsNullOrEmpty(username)) { Response.Redirect("Login.aspx"); return; }

using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["LibraryConn"].ConnectionString))
using (SqlCommand cmd = new SqlCommand(/* query above */, cn))
{
  cmd.Parameters.AddWithValue("@username", username);
  cn.Open();
  using (SqlDataReader dr = cmd.ExecuteReader())
  {
    if (dr.Read()) {
      lblFullName.Text = dr["FullName"].ToString();
      lblDept.Text = dr["Department"].ToString();
      lblUserId.Text = dr["UserID"].ToString();
      lblBorrowed.Text = dr["BorrowedCount"].ToString();
    }
  }
}

Troubleshooting & cautions: always use parameterized queries (no string concatenation), store the connection string in web.config, check that ReturnDate is NULL for active borrows, and handle a missing Session or unauthenticated user. For better performance store UserID in Session at login and use it in the WHERE clause instead of username. Consider hashing passwords and using the ASP.NET Membership/provider model later when you’re ready.

Recommended Answers

All 4 Replies

I'm not sure of what U are asking.
Well I guess your question is
how to show the status of the user or his details?

If thats your question then the most effective way will be to use a Database and provide a Login authentication and get the user information from the database.

Did it answer your question?

yes that is it but i just begginer so I don't know how can i do it plz give a advice and ASAP give me example !!
I actually build a library managment so if student logod and I want to show on display that student has lend any book and some of profile that studen department something like that sorry 4 my english is too bad

Do this step by step.

Create a database.
a. Create the necessary tables and populate all the values belonging to that table(Library details).
b. Create two tables, one for Registering the username and password and other for storing the users details and name it UsertableDetails..(Its up to you how to design the database)

This is the link to registration page.
http://www.daniweb.com/tutorials/tutorial23605.html

and this is the link to authentication page
http://www.daniweb.com/techtalkforums/thread19303.html

c.Now what ever values you want to retrieve for a particular user, retrieve it from UsertableDetails.

You should be fine.

yes i saw that code but that au authentication page code is using access base in my case sql server 2000 so I can't do dislplayed his info from database i mean if student lend book and his status page displayed he borrowed already 1 book like that info i want show my web form

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.