Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 9th, 2006, 7:38 AM   #1
biran
Newbie
 
Join Date: Apr 2006
Posts: 11
Rep Power: 0 biran is on a distinguished road
Lightbulb oledb update record problem

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 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());
}
}
}
......................................................
please as sooon as posible feedback me.
thank you
biran is offline   Reply With Quote
Old May 9th, 2006, 7:43 AM   #2
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
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
nnxion is offline   Reply With Quote
Old May 9th, 2006, 7:46 AM   #3
biran
Newbie
 
Join Date: Apr 2006
Posts: 11
Rep Power: 0 biran is on a distinguished road
hi nnxion
i am doing this for 2 days but i am failed please if you have idia give me solution.
thanks
biran is offline   Reply With Quote
Old May 9th, 2006, 9:21 AM   #4
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
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
nnxion is offline   Reply With Quote
Old May 11th, 2006, 9:22 AM   #5
biran
Newbie
 
Join Date: Apr 2006
Posts: 11
Rep Power: 0 biran is on a distinguished road
hi all,
thanks for not supporting.
finelly, after 3 dyas i did it. and thanks for question viewer.

thanks
biran is offline   Reply With Quote
Old May 11th, 2006, 10:51 AM   #6
nnxion
Programming Guru
 
nnxion's Avatar
 
Join Date: Jun 2005
Location: elemental plane
Posts: 1,429
Rep Power: 5 nnxion is on a distinguished road
Quote:
Originally Posted by biran
thanks for not supporting.
Hey, it's your problem, if you don't specify the problem then don't get pissed at us. If you tried it for 3 days, then you had enough time to specify what the problem was, we don't have your environment set up, so it takes us a lot of time, and you know what they say: time is money.
__________________
"Employ your time in improving yourself by other men's writings, so that you shall gain easily what others have labored hard for."
-- Socrates
nnxion is offline   Reply With Quote
Old May 12th, 2006, 12:13 AM   #7
biran
Newbie
 
Join Date: Apr 2006
Posts: 11
Rep Power: 0 biran is on a distinguished road
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.
biran is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:55 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC