i want to change password.... my password successfully updated but problem is that when i'm typeing different password in textbox2 nd Textbox3. Password Changed based on textbox3.....i want to check password 1st in textbox2 and textbox3. Please Check my coding nd Give me Suggestion where i'm doing mistake.......pls rply on my mail id [email protected]
con.Close();
con.Open();
string a;
a = textBox1.Text;
if (textBox3.Text != textBox2.Text)
{
MessageBox.Show("Password Not Match With new Password",a);
textBox3.Focus();
}
cmd = new SqlCommand("select* from login where password = '" + a + "'", con);
SqlDataReader dr;
dr = cmd.ExecuteReader();
if (dr.Read())
{
con.Close();
con.Open();
SqlCommand cmd1;
SqlDataReader dr1;
if (textBox3.Text!= textBox2.Text)
{
cmd1 = new SqlCommand("update login set password = '" + textBox3.Text + "' where password = '" + a + "'", con);
dr1 = cmd1.ExecuteReader();
MessageBox.Show("Your Password Successfully changed");
}
else
{
MessageBox.Show("Incorrect Passoword");
}
Satyapriya NayakPosted Apr 7, 2013, 6:24 AM
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace Forgot_password
{
public partial class Form1 : Form
{
string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["dsn"];
OleDbCommand com;
string str;
byte up = 0;
public Form1()
{
InitializeComponent();
}
private void btn_change_Click(object sender, EventArgs e)
{
OleDbConnection con = new OleDbConnection(ConnectionString);
if (textBox3.Text != textBox2.Text)
{
MessageBox.Show("confirm password not matching with new passsword");
textBox3.Focus();
return;
}
try
{
con = new OleDbConnection(ConnectionString);
con.Open();
str = "select * from login";
com = new OleDbCommand(str, con);
OleDbDataReader reader = com.ExecuteReader();
while (reader.Read())
{
if (textBox1.Text == reader["empid"].ToString())
{
up = 1;
}
}
if (up == 1)
{
str = "update login set newpwd='" + textBox3.Text + "' where empid='" + textBox1.Text + "'";
com = new OleDbCommand(str, con);
com.ExecuteNonQuery();
MessageBox.Show("Password changed");
}
else
{
MessageBox.Show("Please enter correct empid and Newpassword");
textBox1.Focus();
}
reader.Close();
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}