ADO.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 52
Number of posts: 66

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Updating Values entered by User in form to database Posted by s2009 on 19 Jun 2009 at 3:27 AM
Hi all,

I am trying to create an application which involves the User to change the password.

I am using Microsoft Visual Studio for developing the Graphical User Interface and Microsoft SQL server as the back-end.

I have created a separate form which allows the user to change the password.

However I am unaware of how the particular password will be updated to the Database.

I have tried the following code for updating the new password to the database but it is not working.

There is no error in the code when compiling and running but the password is not updated in the database.

Coding:

UserID = txtUserID.Text;
try
{
SqlCommand objSqlCommand = new SqlCommand("update NewUserRegister set Password = @Password where UserID = @UserID",objSqlConnection);

SqlParameter sql;
sql = objSqlCommand.Parameters.Add("@UserID", SqlDbType.Int);
sql.Value = UserID;

MessageBox.Show("Password Updated Successfully");
}
catch (SqlException e1)
{
MessageBox.Show(e1.Message, "Error Information", MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
catch(System.Exception e2)
{
MessageBox.Show(e2.Message, "Error Information", MessageBoxButtons.OK, MessageBoxIcon.Hand);
}

Can any one help me out with the correct code snippet I should use to update the password?

I am in urgent need of completing this task. Please reply me soon..

Thanks in advance!!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.