![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2006
Posts: 11
Rep Power: 0
![]() |
Hi all,
i am having a problem please help me. actualy i am trying to change password. i tryed like this but its give me update syntax error. .............................................. private void ChangePassBtn_Click(object sender, EventArgs e) { if (npass1.Text != npass2.Text || npass1.Text == "" || npass2.Text == "") { MessageBox.Show("New password Not match or incorrect entry"); } else { try { string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=data\\security.mdb;Jet OLEDB atabase Password=computer";OleDbConnection myConn = new OleDbConnection(strConn); myConn.Open(); string constr = @"Select userid,password From Admins"; OleDbCommand inst = new OleDbCommand(constr, myConn); OleDbDataReader reader = inst.ExecuteReader(); while (reader.Read()) { uid.Text = reader[0].ToString();//uid is hiden tbox upass.Text = reader[1].ToString();//upass is hidden tbox } myConn.Close(); reader.Close(); // string r1, r2; r1 = uid.Text; r2 = upass.Text; if (r1 == userid.Text && r2 == password.Text) { string strCon = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=data\\security.mdb;Jet OLEDB atabase Password=computer";OleDbConnection myCon = new OleDbConnection(strCon); myCon.Open(); string strUpdt = "UPDATE admins SET password='" + npass1.Text + "'"; OleDbCommand myCommand = new OleDbCommand(strUpdt, myCon); myCommand.ExecuteNonQuery(); MessageBox.Show("Password Successfully changed"); myCon.Close(); } else { MessageBox.Show("Error"); } } catch(Exception ed) { MessageBox.Show("error:\n" + ed.ToString()); } } } ...................................................... please as sooon as posible feedback me. thank you |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Code tags please.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#3 |
|
Newbie
Join Date: Apr 2006
Posts: 11
Rep Power: 0
![]() |
hi nnxion
i am doing this for 2 days but i am failed please if you have idia give me solution. thanks |
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Syntax error of what? These are code tags:
private void ChangePassBtn_Click(object sender, EventArgs e)
{
if (npass1.Text != npass2.Text || npass1.Text == "" || npass2.Text == "")
{
MessageBox.Show("New password Not match or incorrect entry");
}
else
{
try
{
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=data\\security.mdb;Jet OLEDBatabase Password=computer";
OleDbConnection myConn = new OleDbConnection(strConn);
myConn.Open();
string constr = @"Select userid,password From Admins";
OleDbCommand inst = new OleDbCommand(constr, myConn);
OleDbDataReader reader = inst.ExecuteReader();
while (reader.Read())
{
uid.Text = reader[0].ToString();//uid is hiden tbox
upass.Text = reader[1].ToString();//upass is hidden tbox
}
myConn.Close();
reader.Close();
//
string r1, r2;
r1 = uid.Text;
r2 = upass.Text;
if (r1 == userid.Text && r2 == password.Text)
{
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=data\\security.mdb;Jet OLEDBatabase Password=computer";
OleDbConnection myCon = new OleDbConnection(strCon);
myCon.Open();
string strUpdt = "UPDATE admins SET password='" + npass1.Text + "'";
OleDbCommand myCommand = new OleDbCommand(strUpdt, myCon);
myCommand.ExecuteNonQuery();
MessageBox.Show("Password Successfully changed");
myCon.Close();
}
else
{
MessageBox.Show("Error");
}
}
catch(Exception ed)
{
MessageBox.Show("error:\n" + ed.ToString());
}
}
}
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
#5 |
|
Newbie
Join Date: Apr 2006
Posts: 11
Rep Power: 0
![]() |
hi all,
thanks for not supporting. finelly, after 3 dyas i did it. and thanks for question viewer. thanks |
|
|
|
|
|
#6 | |
|
Programming Guru
![]() Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5
![]() |
Quote:
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for." -- Socrates |
|
|
|
|
|
|
#7 |
|
Newbie
Join Date: Apr 2006
Posts: 11
Rep Power: 0
![]() |
nnxion
i already wrote about error ->update syntax error. i change database field it was userid and password and i changed userid to users and password to pass so its same cod work properly. i don't know why database coused this code. anyway thank you for you aprociation. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|