this is my code

If Me.txtOldPassword.Text = pwd Then
                Dim oledbcom1 As New OleDb.OleDbCommand
                oledbcom1.CommandText = "Update login Set password = ?"

                oledbcom1.Connection = oledbcon

                oledbcom1.Parameters.Add("?", OleDb.OleDbType.VarChar)
                oledbcom1.Parameters(0).Value = Me.txtNewPassword.Text.Trim

                oledbcom1.ExecuteNonQuery()

                oledbcon.Close()
end if

Sknake is right, you need to provide the error message for anyone to provide detailed help other then guessing at whatelse might be going on in your code. For instance, I do not see where you are opening the database connection although you may be doing that elsewhere in the program.

Also is this a single user program, meaning there can be only one person with an account and login? I dont see a where clause in your update query string meaning if there is more then one account, it will update every record in that table.

Comments
N.A

this is my code

If Me.txtOldPassword.Text = pwd Then
                Dim oledbcom1 As New OleDb.OleDbCommand
                oledbcom1.CommandText = "Update login Set password = ?"

                oledbcom1.Connection = oledbcon

                oledbcom1.Parameters.Add("?", OleDb.OleDbType.VarChar)
                oledbcom1.Parameters(0).Value = Me.txtNewPassword.Text.Trim

                oledbcom1.ExecuteNonQuery()

                oledbcon.Close()
end if

I am going to suggest you name the params.

Ex:

oledbcom1.CommandText = "Update login Set password = @Password"

                oledbcom1.Parameters.Add("@Password", OleDb.OleDbType.VarChar).Value = Me.txtNewPassword.Text.Trim

Hope this Helps...

the error that i get is
"syntax error in update statement"
with the title..."oledb exception was unhandled"
i am using access 2007 and visual studio 2005
sorry for late reply...

Field name password is a access's reserved word.
Use,

str="update login set [password]=?"

Edited 7 Years Ago by __avd: n/a

Comments
Misguidance

I could not get it to work using the '?' as the parameter name. I had to give it an actual name; like CodeDoctor suggested above.

To comment about the above post, "Password" is not a reserved keyword in ms access.

Comments
Don't misguide please.

Field name password is a access's reserved word.
Use,

str="update login set [password]=?"

thnx a ton tht worked fine.....

Welcome TomW,

Read this - SQL Reserved Words

SUMMARY:
The following list includes all words reserved by the Microsoft Jet database engine for use in SQL statements . The words in the list that are not in all uppercase letters are also reserved by other applications. Consequently, the individual Help topics for these words provide general descriptions that do not focus on SQL usage.

http://sqlserver2000.databases.aspfaq.com/what-are-reserved-access-odbc-and-sql-server-keywords.html

Comments
Providing incorrect misleading information

Read post #10.

..list includes all words reserved by the Microsoft Jet database engine for use in SQL statements .

Again your first link is to a version the user stated he wasnt using and your second link even confirms it is not a reserved word for the program!

This question has already been answered. Start a new discussion instead.