CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.club_web_site_starter_kit Tags:
Item Type: NewsGroup Date Entered: 5/17/2006 12:38:16 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 27 Views: 39 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
28 Items, 2 Pages 1 2 |< << Go >> >|
tsaren
Asp.Net User
LastLoginDate (2 hours off)5/17/2006 12:38:16 PM

0/0

Hi!

I was wondering if you people also find the LastLoginDate to be 2 hours off in the aspnet.membership table. It is a little bit annoying as I show the name and time of the last 5 logins.

 

Regards,

Tommy

chunshahab
Asp.Net User
Re: LastLoginDate (2 hours off)5/17/2006 1:30:36 PM

0/0

I think it puts the GMT time. We may have to do the calculation/conversion ourselves.
Help Whenever You Can
Live Without Regret
jeff@zina.com
Asp.Net User
Re: LastLoginDate (2 hours off)5/17/2006 1:35:12 PM

0/0

tsaren:

I was wondering if you people also find the LastLoginDate to be 2 hours off in the aspnet.membership table. It is a little bit annoying as I show the name and time of the last 5 logins.

Mine's five hours off.  If you want to correct this, move two time zones west.  :)

It's GMT, you need to do an offset for the correct time.  This could be done before saving the date to the database, or in the retrieval for display.

Jeff


Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue.
chunshahab
Asp.Net User
Re: LastLoginDate (2 hours off)5/17/2006 1:47:14 PM

0/0

I did a test. I think it is putting the UTC time rather than the system time
Help Whenever You Can
Live Without Regret
MrLunch
Asp.Net User
Re: LastLoginDate (2 hours off)5/17/2006 5:38:33 PM

0/0

>move two time zones west.  :) ha ha!

You can't change the date from UTC before it's saved in this case, as different login controls will set this date and expect it to be in UTC.

What you need to do is change it to local time when you display it, which is easy:

dim utcdate as date
... get the date from database
localdate = utcdate.ToLocalTime()


Mark Bracewell
Forums Starter Kit
tsaren
Asp.Net User
Re: LastLoginDate (2 hours off)5/17/2006 6:53:26 PM

0/0

Thank you people for your help. I will implement it tomorrow. Strange thing it does not use the server time.
tsaren
Asp.Net User
Re: LastLoginDate (2 hours off)5/17/2006 7:46:16 PM

0/0

Hi again!

I got the sql for it:

select

dateadd(hh,2,lastlogindate) from dbo.aspnet_membership

where

email ='abc123@cnn.com'

/Tommy

MrLunch
Asp.Net User
Re: LastLoginDate (2 hours off)5/17/2006 8:32:40 PM

0/0

Hiya Tommy,

that will work, but only if you live in Sweden and there's no daylight savings time :)

Where I live, sometimes we are 7 hours different from UTC, sometimes 8.

The date function ToLocalTime() takes this into account, so if you use that, you can move your software to New York and it will still work correctly. That might never be an issue for you, but I think it's a good practice to try to write code that's going to run properly regardless of where it's hosted.

I think this is why the date is stored as UTC in the first place, because it means you *can* write code that converts it to local time (not just server local time either, maybe you'll eventually want to time to appear in the user's local time, so if I browse to your site on the other side of the world, the time I see is *my* local time, not Swedish time).


Mark Bracewell
Forums Starter Kit
tsaren
Asp.Net User
Re: LastLoginDate (2 hours off)5/18/2006 5:28:53 AM

0/0

You are so right "Herr Lunch"! /hey thanks again for the forum. It is working great.

lexy
Asp.Net User
Re: LastLoginDate (2 hours off)5/19/2006 9:02:21 AM

0/0

Hi ,
 
I am trying to show the last Logindate like Tommy. (and more of that sort of data when I succeed)
 
I have been trying to do that using SQLdatasource and a gridview,
 
But I can't synchronize it with the current (logged-in) user.
 
Something like blahblahblah WHERE userid = @userid, but I am drawing blanks.
Also I could be doing this the wrong way altogether of course.....
 
Could someone point me in the right direction?
 
Thanks,
Lex

I use VB
tsaren
Asp.Net User
Re: LastLoginDate (2 hours off)5/19/2006 12:18:17 PM

0/0

This does not fix Lex problem, but it was the final solution to my problem.

 

 <ItemTemplate>
                            <%# Convert.ToDateTime(Eval("lastlogindate")).ToLocalTime() %>
 </ItemTemplate>

 

Regards,

 

Tommy

chunshahab
Asp.Net User
Re: LastLoginDate (2 hours off)5/19/2006 1:02:02 PM

0/0

Lex,

Please show your SQL statement (blahblahblah WHERE userid = @userid) so we can take a look.

Thanks.


Help Whenever You Can
Live Without Regret
lexy
Asp.Net User
Re: LastLoginDate (2 hours off)5/19/2006 1:14:56 PM

0/0

Hi,

SELECT     distinct top 1 UserId, LastLoginDate
FROM         vw_aspnet_MembershipUsers
WHERE     (UserId = @UserId)

With the where clause builder I choose for:

  1. column: UserId
  2. operator: =
  3. Source: Querystring
  4. Paramater properties ????
  5. default value ????

That's about it.

Regards,

Lex


I use VB
chunshahab
Asp.Net User
Re: LastLoginDate (2 hours off)5/19/2006 1:28:07 PM

0/0

Lex,

Are you sure that you are passing the UserId not the UserName?

The user id is a long uniqueidentifier.

Thanks.

 


Help Whenever You Can
Live Without Regret
lexy
Asp.Net User
Re: LastLoginDate (2 hours off)5/19/2006 1:56:50 PM

0/0

Hi,

Well I choose it because it defines the user uniquely, (so does Username I guess)

In both cases my problem seems to be to hold it against the current logged-in user.

Thanks,

Lex

 


I use VB
MaineOne
Asp.Net User
Re: LastLoginDate (2 hours off)5/19/2006 4:13:35 PM

0/0

Hi lex here is an example of how to build the select statement in the script and call it from the sqldatasource.

I find this easier for manipulating the query string. You could also place this in the App_Code folder so it can be called by other pages. For now try it in the page you are working on.

Public Sub Get_Authentication(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreLoad

Dim GridViewSQL As String

If

User.IsInRole("Administrators") = True Then

ViewStatus = 1

GridViewSQL =

"SELECT NameFile, PathFile, FileDesc, IdFile, ViewStatus ,LastUpdated,DownLoads FROM dbo.aspsk_Files WHERE (ViewStatus" & ">=" & ViewStatus & ")"

SqlDataSource1.SelectCommand = GridViewSQL

End If

End

Sub

 

The SqlDatasource should look like this.

<

asp:SqlDataSource ID="SqlDataSource1" runat="server" OnLoad="Get_Authentication" ConnectionString="<%$ ConnectionStrings:ClubSiteDB %>">

</asp:SqlDataSource>

Also Make sure the UserId is formatted correcty before executing the statement. My solution is,

Dim

UserId As String

UserId =

"{" & Membership.GetUser().ProviderUserKey.ToString & "}"

This gets the current logged in User ID

Any questions you know were to find me.


Support@aspsksolutions.com

MrLunch
Asp.Net User
Re: LastLoginDate (2 hours off)5/19/2006 4:29:48 PM

0/0

What exactly are you trying to do Lex (in terms of what the final result is supposed to be)?

Getting the current user last login date doesn't need a database query, it's as simple as

Membership.GetUser().LastLoginDate

To get the last login of some other user, do

Membership.GetUser(memberid).LastLoginDate
or
Membership.GetUser(username).LastLoginDate

I think Tommy was using a query because he was getting the last N people who logged in, but you can do a lot of this sort of thing without going to the database, for example, to get a list of all online users, and another list of all users who logged in in the last hour, you could do:

Dim allMembers As MembershipUserCollection = Membership.GetAllUsers()
Dim myOnlineUsers As MembershipUserCollection = New MembershipUserCollection
Dim myRecentUsers As MembershipUserCollection = New MembershipUserCollection
For Each person As MembershipUser In allMembers
    If person.IsOnline Then
        myOnlineUsers.Add(person)
        myRecentUsers.Add(person)
    ElseIf person.LastLoginDate > DateAdd(DateInterval.Hour, -1, Now) Then
        myRecentUsers.Add(person)
End If
Next

GridView1.DataSource = MyOnlineUsers

GridView2.DataSource = myRecentUsers

DataBind()

or something like that.

As an aside - there's something about the club kit that can lead you down a painful path, and that is the fact that the club kit has this Fistname & Lastname in the memberinfo table. If you want to display these names, then you're forced to do a query or join against that table to get the names. I think that's a bad idea for two reasons - one is that it's totally possible for there to be 2 or more John Smiths in the memberinfo table, the other is that the user can change those values, and conceal who they are (or were). That being said, I did the join in my forums code. I shouldn't have. I think you should display the username (like the login control does when you're logged in).

On another more obscure note - the username field in the aspnet DB isn't guranteed to be unique - since that db can hold user data for more than one application, thus it's a bad idea to query that db WHERE username = 'foo', much better to user the Membership class to get the user (since it will construct the query using the correct application name).

Anyhow, I strongly recommend against querying the aspnet DB at all, unless you must. There are programmatic ways to get that info that are much safer. If you need to get data about users, roles and whatnot and use that as a datasource for a grid or something, consider creating a class that gets the data and exposes it as an ObjectDataSource.

OK, off my soapbox now :)


Mark Bracewell
Forums Starter Kit
lexy
Asp.Net User
Re: LastLoginDate (2 hours off)5/19/2006 5:51:58 PM

0/0

Hi Frank,

 

I transposed your code as follows:

Dim GridViewSQL As String

Dim UserIdhaal As String

UserIdhaal =

"{" & Membership.GetUser().ProviderUserKey.ToString & "}"

GridViewSQL =

"SELECT [LastLoginDate], [UserId] FROM [vw_aspnet_MembershipUsers] WHERE (UserId" & ">=" & UserIdhaal & ")"

SqlDataSource1.SelectCommand = GridViewSQL

 

But then I have a problem that on loading the page I get

Object reference not set to an instance of an object.

That makes sense of course since I should run the code after logging in

 

 

So I tried it  in the Logged-in template:

Protected Sub lv1_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs)

Dim GridViewSQL As String

Dim UserIdhaal As String

UserIdhaal =

"{" & Membership.GetUser().ProviderUserKey.ToString & "}"

GridViewSQL =

"SELECT [LastLoginDate], [UserId] FROM [vw_aspnet_MembershipUsers] WHERE (UserId" & ">=" & UserIdhaal & ")"

Dim sqldta As System.Web.UI.WebControls.Login = lv1.FindControl("Login1")

Dim jawat As SqlDataSource = CType(sqldta.FindControl("SqlDataSource6"), SqlDataSource)

jawat.SelectCommand = GridViewSQL

End Sub

 

But obviously at least one problem  Smile [:)] because the grid stays empty.

Thanks in advance,

Lex

 


I use VB
lexy
Asp.Net User
Re: LastLoginDate (2 hours off)5/19/2006 6:00:14 PM

0/0

Hi Mark,

This looks short and neat I must say. But as I am trying to put it in default.aspx I don't know where exactly to put it.

Sort of the same problem as described in the previous post: When the page loads the user is not logged on yet.

But it certainly is a piece of code that could come in handy at all sorts of pages.

Thanks,

Lex

 

 


I use VB
MaineOne
Asp.Net User
Re: LastLoginDate (2 hours off)5/19/2006 6:59:06 PM

0/0

I'm afraid I'm a little confused, what is the reasoning for sqldta and jawat

I was just showing how you could build a query string in the script for a Sqldatasource, if your just trying to fill a gridview that uses Sqldatasource6 then just use SqlDatasource6.selectcommand =  GridViewSql.

Dim sqldta As System.Web.UI.WebControls.Login = lv1.FindControl("Login1")

Dim jawat As SqlDataSource = CType(sqldta.FindControl("SqlDataSource6"), SqlDataSource)

jawat.SelectCommand = GridViewSQL

I do believe Mark has offered a better solution, you may just need to play around with it to get it to do what you want. The MembershipProvider is a great feature with Asp.net and should be a priority for anyone to learn(including myself)


Support@aspsksolutions.com

28 Items, 2 Pages 1 2 |< << Go >> >|


Free Download:

Books:
Linux For Dummies Authors: Dee-Ann LeBlanc, Richard Blum, Pages: 411, Published: 2007
Hacking Exposed: Network Security Secrets and Solutions Authors: Stuart McClure, Joel Scambray, George Kurtz, Pages: 729, Published: 2001
Hacking iSeries Authors: Shalom Carmel, Pages: 0, Published: -1
Core PHP Programming: Using PHP to Build Dynamic Web Sites Authors: Leon Atkinson, Pages: 769, Published: 2001
Pro ASP.NET 3.5 in C# 2008 Authors: Matthew MacDonald, Mario Szpuszta, Pages: 1498, Published: 2007
ASP.NET AJAX Programming Tricks Authors: Matthew David Ellis, Matthew Ellis, Pages: 388, Published: 2007

Web:
LastLoginDate (2 hours off) - ASP.NET Forums
how do i change myt last login date permanently | Help For Beginners last seen 1 day 15 hours ago. Re: how do i change myt last login date permanently ... Bunch of words to display"Last Login: 6/5/2008 How do you take off the Last Login: date on MY SPACE? - Yahoo! Answers How do you take off the Last Login: date on MY SPACE? I DONT WANT PEOPLE TO SEE THE DATES .... Member since: September 21, 2008; Total points: 262 (Level 2) ...
select next highest salary or last login date ... - bytes Re: select next highest salary or last login date . ... select the top two values of xxxx from yyyyy where the_grouping = 'ZZZZZ', sorted in descending order; when reading the .... [IMG] code is Off. HTML code is Off. Trackbacks are On ...
User's Last Login date and time - BigBlueBall Forums Posts: 2. wiseguy244 is on a distinguished road (10) ... I keep checking to see if that person is online every few hours but they never (i ... login/logoff it will show you in the box and what time they signed on/off. ...
Hiding Last Login Date on Myspace Profile Hacks · Orkut Applications Follow Step 1 and 2 for Public Profiles If you have private profiles Follow Step 3 ... States
Last Login: Today ...
Last login date for users in AD - Computing.Net How can I find out the last login date for a user in AD? ... Over 90% answered within 24 hours! Click here to sign up now, .... The problem that those two lines should be, changing the )( to ... I have a reletively long one but it has work for months, now all of a sudden half of it is cut off, I g. ...
Last Login Date of a user in Business Objects. Can you please help me, How to find out last Login Date of a user in Business Objects? Thanks in advance, ... (And, 2-tier full-client access is not captured by the WebI server.) ... Page 1 of 1, All times are GMT - 6 Hours ... About BOB, • Forum FAQ, • BOB Projects, • Shop@BOB Reviews, Off Topic ...
Last Login date for users - dBforums Last Login date for users Unix Shell Scripts. ... Registered User. Join Date: Jan 2008. Posts: 2 ... [IMG] code is Off. HTML code is Off ...
Why can't my last login date and time be displayed whenever I ... Lesson 21 - Making your own Functions · Lesson 22 - Starting off with Databases ... I have problems with my last login date and time because whenever I login ... 3 weeks 2 days ago; Delete an object that have been referenced elsewhere ...




Search This Site:










problem in treeview

property and enum

on what point exactly is user logged in to site?

files not found error

returnurl under masked domain name not working

categorised view

populating application variables/constants and enumerations from database

using a scripting language

navigation control

process.start from asp.net application

visual studio .net 2005 beta 2

cant switch to design view

can someone explain postback?

subject line blank on registration email notifications

password length and style

could not center the text in an horizontal menu control

import users or subscribers

which version of service pack 2 do i need to install visual studio 2005?

create pages on the fly using ihttphandler. need advice

localization terms of use

get connection string from web.config and secure that connection

dataadapter components not appearing in vs 2005

sending e-mail problem

what is the deal

how to stop returnurl?

asp:listview

newb question (i think) - how to preload data in custom module?

storing in context

skin error - dnn no longer works

problem with images

 
All Times Are GMT