Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am trying to gather this information from the default user table that is created by ASPNETDB.MDF when using login control is there any way i can get last login time also?


C#
string str = "select username, LastActivityDate from aspnet_Users";
        SqlDataAdapter da = new SqlDataAdapter(str, con);
        DataTable dt = new DataTable();
        da.Fill(dt);
        GridView1.DataSource = dt;
        GridView1.DataBind();


its showing output like this:
a2ulthakur 17-04-2013 07:20:02

but its not showing the accurate time.
Posted
Updated 16-Apr-13 21:26pm
v2

1 solution

try this code
MembershipUser mu = Membership.GetUser("username");
EmailLabel.Text = mu.Email;
IsOnlineLabel.Text = mu.IsOnline.ToString();
LastLoginDateLabel.Text = mu.LastLoginDate.ToString();
CreationDateLabel.Text = mu.CreationDate.ToString();
LastActivityDateLabel.Text = mu.LastActivityDate.ToString();

also refere following msdn links
MembershipUser Class[^]
MembershipUser.LastActivityDate Property[^]
 
Share this answer
 
v2
Comments
a2ulthakur 17-Apr-13 3:47am    
Pallavi does this fetch value from aspnet_users tabel?
Pallavi Waikar 17-Apr-13 3:52am    
yes.... u can access that aspnet_users tabel ...by MembershipUser class..go to ur .cs page and try it...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900