.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
ASPEvil
Jean Paul
SP
satyapriyanayak
Ashutosh Jha

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

change password coding in asp.net,c#,ms-access database

Posted By: deven     Posted Date: April 17, 2013    Points:5   Category :ASP.Net
i am desiging a change password screen in asp.net,c#,MS-access database i m having 4 fields userid, oldpassword, newpassword confirm password

I M NOT GETTING RESULT THE COUNT RETURNS 0

my code is as follows
MY register table contains user_id,passwd field which i have used here

try

{

OleDbConnection myCon = new OleDbConnection(ConfigurationManager.ConnectionStrings["vhgroupconnection"]
.ConnectionString);
myCon.Open();

string userid = txtuserid.Text;
string oldpass = txtoldpass.Text;
string newPass = txtnewpass.Text;
string conPass = txtconfirmpass.Text;

string q = "select user_id,passwd from register where user_id = @userid and passwd = @oldpass";

OleDbCommand cmd = new OleDbCommand(q, myCon);



cmd.Parameters.AddWithValue("@userid", txtuserid.Text);

cmd.Parameters.AddWithValue("@oldpass", txtoldpass.Text);

OleDbDataReader re = cmd.ExecuteReader();
re.Read();

if (re["user_id"].ToString() != String.Empty && re["passwd"].ToString() != String.Empty)
{
if (newPass.Trim() != conPass.Trim())
{
lblmsg.Text = "New Password and old password does not match";

}
else
{
q = "UPDATE register SET passwd = @newPass WHERE user_id =@userid";
cmd = new OleDbCommand(q, myCon);
cmd.Parameters.AddWithValue("@userid", txtuserid.Text);
cmd.Parameters.AddWithValue("@newPasss", txtnewpass.Text);



int count = cmd.ExecuteNonQuery();

if (count > 0)
{
lblmsg.Text = "Password changed successfully";
}
else
{
lblmsg.Text = "password not changed";
}
}
}
}
catch(Exception ex)
{
throw ex;
}


plz help to find the error

Responses
Author: satyapriyanayak             
Posted Date: April 17, 2013     Points: 20   

http://www.c-sharpcorner.com/uploadfile/satyapriyanayak/change-a-password-in-asp-net/

If this post helps you mark it as answer
Thanks
Author: deven             
Posted Date: April 18, 2013     Points: 20   

NO i tried this example also.
is thr any code which has Ms-access database


Author: deven             
Posted Date: April 18, 2013     Points: 20   

I GOt the answer i changed my update query as: q = "UPDATE register SET passwd = '"+txtnewpass.Text+"' WHERE user_id ='"+txtuserid.Text+"'";

it worked successfully
thank you for your help

Author: Andrew Hudson             
Posted Date: July 23, 2013     Points: 20   

Hi this is a very helpful information for change password as language asp.net,c#,MS-access database but this code is not working. if given the right code help more helpful. i request to all if any body have a right code of change password as any language pls post the threat.



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend