473,943 Members | 16,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Kindly help me with change password - code attached.

3 New Member
Hi, Please see my below code to change password. Here i need to check for old password from database and need to update new password. But when i try to submit by giving wrong old password ,its redirecting me to PasswordSet.asp x whereas it shd give message Invalid Old Password. It shd redirect me only when user gives correct old password and enters new password. please help.
Expand|Select|Wrap|Line Numbers
  1. Private Sub btn_submit_ServerClick(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btn_submit.ServerClick
  2.  
  3.         Dim myConnection, myCommand
  4.         Dim intUserCount As Integer
  5.         Dim strSQL As String
  6.  
  7.         strSQL = "UPDATE EPSusers SET Password='" & Replace(txt_newpassword.Text, "'", "''") & "' " & "WHERE UserName='" & Replace(txt_uid.Text, "'", "''") & "' " _
  8.          & "AND Password='" & Replace(txt_oldpassword.Text, "'", "''") & "';"
  9.  
  10.         myConnection = New SqlConnection("Server=(local);Database=testdb;uid=sa;password=courage")
  11.  
  12.         myCommand = New SqlCommand(strSQL, myConnection)
  13.  
  14.         myConnection.Open()
  15.         intUserCount = myCommand.ExecuteScalar()
  16.         myConnection.Close()
  17.  
  18.         If txt_oldpassword.Text.Trim = "" Then
  19.             lblStatus.Text = "Invalid Old Password!"
  20.             'Exit Sub
  21.             FormsAuthentication.SetAuthCookie(txt_oldpassword.Text, True)
  22.             lblInvalid.Text = "Your User Name and Password cannot be located, try again.!!!."
  23.             'Session("UName") = txt_uid.Text
  24.             'Response.Redirect("PasswordSet.aspx")
  25.         Else
  26.             'lblInvalid.Text = "Your User Name and Password cannot be located, try again.!!!."
  27.             Response.Redirect("PasswordSet.aspx")
  28.         End If
  29.     End Sub
Aug 5 '07 #1
2 1720
kenobewan
4,871 Recognized Expert Specialist
Shouldn't you check the password before you try to update?
Aug 5 '07 #2
vanc
211 Recognized Expert New Member
Yeah, that's exactly what your code should do!!! If you input wrong password, except "" password, your piece of code will Redirect you to that page not returns the invalid message, if you want to see that message you should input blank password.
If you want to display invalid password message you have to modify your code.

cheers.
Aug 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1376
by: PerryC | last post by:
I am able to create a script that will send a report as email attached rtf file. However, is there a way to make this attached file password protected? i.e. the recipient needs a password to open up the attached rtf? Thanks in advance, Perry
13
4967
by: Javier Gomez | last post by:
Is it posible to change by code (in a form) the active .mdw by another one ? When I open the DB I have the system.mdw active after some procesess I need to change to another secure.mdw and make active, but I bought like it to make it by code inside of a form in button command click. (I do not want to make it thought tools bars menu.) Can anybody help ?
10
9920
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
1
10468
by: John Beard | last post by:
I downloaded the attached code from MS. It flips on the "User Cannot Change Password" on a user in AD and works great from a console or windows app, but when put into an ASP.NET app I get a "The security ID structure is invalid." error when trying to assign the new security descriptor. I am running in Windows Authentication mode with IIS set to Integrated security on an XP box. Does anyone have a work around for this? Thanks in...
6
5154
by: Jan | last post by:
Hi: I have created a secured database for a client. For various reasons, I don't want the client to have full persmissions for the database; they aren't in the admins group. I have instead tried to create a second group, called "localAdmin," for the admin-type person at the client. I want this group to be able to do some basic admin-type stuff, including adding new users and clearing passwords if users forget theirs. I can't seem to...
1
1631
by: ckpoll2 | last post by:
Hello, I have visual basic code tied to a command button that requires a password before opening a form. When the password is entered, it appears as typed rather than as "******" or something like that. Is there any way to hide what is being typed? Below is the code that I'm currently using. Thanks, Charlie
3
7958
by: W C Hull | last post by:
We have a request from Auditing to modify the password an a local workstation administrative account every 90 days. We are developing two programs - a VB6 GUI program that will allow the administrative support person to enter a new password into an App and have that encrypted password saved in a text file. The second part is a VB6 program that only is a command line program that will open the password text file, read the encrypted...
3
2950
sreekandank
by: sreekandank | last post by:
I want to implement POP3 program in java....I have written the code like... import javax.mail.*; import javax.mail.internet.*; import java.util.*; import java.io.*; public class POP3Client { public static void main(String args) {
6
4537
by: gavy7210 | last post by:
hello i am using struts 1.2,Eclipse Platform Version: 3.4.2,mySql 5.0.1,jdk 1.5.. i have a login form(jsp) in which a user logs in,in case he doesnt enter his username and/or password an error is displayed using the <ul> tag and <html:errors> in the jsp. in the from class a vaidate method creates an actionerrors object adds all the errors to it and finally returns it. the ids are linked in messageresources.properties and appropriate...
0
10143
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11539
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11133
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11303
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8228
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7393
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6312
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4515
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.