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:
XML
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="changepassword.aspx.cs" Inherits="changepassword" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Change Password</title>
</head>
<body bgcolor="#CCFFFF">
<center>
    <h1><u>Online Shopping Cart</u></h1></center>
    <form id="form1" runat="server">
    <div>
    <p align="center"><font size="5"><b>Change Password</b></font></p>
    <asp:Panel style="position:absolute; top: 143px; left: 458px; height :182px; width: 340px; margin-top: 3px;" ID="Panel1"
        runat="server" BackColor="Silver" BorderColor="#660033"
        BorderStyle="Solid" HorizontalAlign="Center" ScrollBars="Vertical">
        <table align="center" cellpadding="2" cellspacing="2" width="100%">
            <tr>
                <td style="padding-left:10px">
                    User ID</td>
                <td>
                    <asp:TextBox ID="UserId" Runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="padding-left:10px">
                    Old Password</td>
                <td>
                    <asp:TextBox ID="Pwd" Runat="server" TextMode="Password"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="padding-left:10px">
                    New Password</td>
                <td>
                    <asp:TextBox ID="NPwd" Runat="server" CssClass="TblBorder" TextMode="Password"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td height="20" style="padding-left:10px">
                    Confirm Password&nbsp;</td>
                <td>
                    <asp:TextBox ID="CPwd" Runat="server" CssClass="TblBorder" TextMode="Password"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td height="5">
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;</td>
                <td>
                    <asp:Button ID="Submit" runat="server" OnClick="Submit_Click" />
                    &nbsp;&nbsp; <%--<asp:Button ID="Cancel" runat="server" OnClick="Cancel_Click" />
--%></td>
            </tr>
        </table>

   </asp:Panel>
    </div>
    </form>
</body>
</html>


code behind file

protected void Submit_Click(object sender, EventArgs e)
{


SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["sampleConnectionString2"].ToString();
con.Open();
SqlCommand cmd=new SqlCommand("UPDATE Users SET Password='" +NPwd.Text.Trim()+ "' where UserName = '" +UserId.Text+ "' AND Password='" +Pwd.Text+ "'");
cmd.ExecuteNonQuery();
con.Close();
Response.Write("<script language=Javascript>alert('Your Password Has Been Changed,Please Login With New Password')</script>");
Response.Redirect("~/Default.aspx");

}
}

its showing error while updating password in execute nonquery
Posted
Comments
thatraja 29-Feb-12 3:54am    
What's the error message?

1 solution

C#
SqlCommand cmd=new SqlCommand("UPDATE Users SET Password='" +NPwd.Text.Trim()+ "' where UserName = '" +UserId.Text+ "' AND Password='" +Pwd.Text+ "'",con);
 
Share this answer
 
Comments
sankarreddyece 29-Feb-12 3:02am    
update register set password='" + NPwd.Text.Trim() + "' where username = '" + UserId.Text + "' and password='" + Pwd.Text + "'"
i will change this one also again it showing an error
sankarreddyece 29-Feb-12 3:06am    
username password email
sankar ksr740 System.Web.UI.WebControls.TextBox
sankarreddyk ksr740 reddysankark@yahoo.com

this is my database
palraj001 29-Feb-12 4:08am    
what error?

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