Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

SqlConnection.ChangePassword Method (String, SqlCredential, SecureString)

.NET Framework 4.6 and 4.5

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


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.

Type: System.Data.SqlClient.SqlCredential

A SqlCredential object.

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).

  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.


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

.NET Framework

Supported in: 4.6, 4.5
© 2015 Microsoft