Click here to Skip to main content
12,629,804 members (32,617 online)
Rate this:
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL-Server
Dear Friends,

Am working on , c#, SQLSERVER 2005.

In my project, A message must be displayed to user if his password expires.

I have a Registration(Add new user) webform in my project. in that i have fields
Firstname, Lastname,DisplayName,Username,Password,IssueDate,ExpiryDate.

While creating New User, Administrator will enter all information of user FN,LN,DN,Username,Pwd,IssueDate,ExpDate.

Generally the issue date will be default like this 19/07/2012(System date) and the admin need to enter only Expiry year like this 2013.

Suppose, if the user passed the year 2013. a message must be displayed while login
"your Password has Expired, Please contact Administrator"

Please help me , how to solve this.

Thanks in ADVANCE.
Posted 18-Jul-12 22:30pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Let's say for each user you have a expiry year defined.

You need to fetch the expiry year for a user and compare with today's date's year. If they match then the password has expired and you need to show the prompt.
WHERE ExpiryYear >= DATEPART(year,GETDATE())
AND UserID = @currentLoggedInUser
If any data is returned from the query then that user password has expired.
sandeep nagabhairava 19-Jul-12 4:34am
good work sandeep my 5!
Sandeep Mewara 19-Jul-12 4:38am

sandeep nagabhairava 19-Jul-12 4:40am
hoo.. unfortunately i for got it... hold this...
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

you will do a query like this

select 1 from your table where userid= <your userid=""> and getdate = <password expiry="" date="" field="">

if it satisfies 1 will be returned then pass word is expired.
Ranjith Reddy CSE 19-Jul-12 4:04am
am not clear, what is 1. Please explain me boss.
Explain me in detail

Ranjith Reddy CSE 19-Jul-12 4:08am
Suppose if the Users Expiry date is less than todays date. It must display a message like this.

"Your Password has Expired,Please contact administrator"

Thanks , Please help me brothers.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

hi ranjit

You try like this i am, showing in 2tier format for just understanding purpose,

bring Expiry date from Database

Select Max(ExpiryDate) from TABLE where Username='"+txtusername+"' and Password='"+txtpassword+"'

Datetime ExpDate;
              dr = cmd.ExecuteReader();
              if (dr.Read() == true)
                ExpDate=convert.todatetime( dr[0].ToString());
//Show your msg hear
//write yor code hear
i hope this will helps you


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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161205.3 | Last Updated 19 Jul 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100