SqlConnection::ChangePassword Method (String^, SqlCredential^, SecureString^)

.NET Framework (current version)
 

Changes the SQL Server password for the user indicated in the SqlCredential object.

Namespace:   System.Data.SqlClient
Assembly:  System.Data (in System.Data.dll)

public:
static void ChangePassword(
	String^ connectionString,
	SqlCredential^ credential,
	SecureString^ newSecurePassword
)

Parameters

connectionString
Type: System::String^

The connection string that contains enough information to connect to a server. The connection string should not use any of the following connection string keywords: Integrated Security = true, UserId, or Password; or ContextConnection = true.

credential
Type: System.Data.SqlClient::SqlCredential^

A SqlCredential object.

newSecurePassword
Type: System.Security::SecureString^

The new password. newSecurePassword must be read only. The password must also comply with any password security policy set on the server (for example, minimum length and requirements for specific characters).

Exception Condition
ArgumentException
  1. The connection string contains any combination of UserId, Password, or Integrated Security=true.

  2. The connection string contains Context Connection=true.

  3. newSecurePassword is greater than 128 characters.

  4. newSecurePassword is not read only.

  5. newSecurePassword is an empty string.

ArgumentNullException

One of the parameters (connectionString, credential, or newSecurePassword) is null.

.NET Framework
Available since 4.5
Return to top
Show: