How to Change SQL Server Database Password

Waqas Anwar
06 June 2009

If you are connecting SQL Server Database from .NET Applications using a Connection string and you want to change the database password from your C# or VB.NET code, you can use ChangePassword method of SqlConnection class.

string conStrWithOldPassword = "Server=Test; Database=Test; uid=test; pwd=oldpassword;

string newPassword = "newpassword";

SqlConnection.ChangePassword(conStrWithOldPassword, newPassword);