System.Data.SqlClient.SqlConnection.SqlConnection.ChangePassword C# (CSharp) Method

ChangePassword() public static method

public static ChangePassword ( string connectionString, string newPassword ) : void
connectionString string
newPassword string
return void
		public static void ChangePassword (string connectionString, string newPassword)
		{
			if (String.IsNullOrEmpty (connectionString))
				throw new ArgumentNullException ("The 'connectionString' cannot be null or empty.");
			if (String.IsNullOrEmpty (newPassword))
				throw new ArgumentNullException ("The 'newPassword' cannot be null or empty.");
			if (newPassword.Length > 128)
				throw new ArgumentException ("The length of 'newPassword' cannot exceed 128 characters.");
			using (SqlConnection conn = new SqlConnection (connectionString)) {
				conn.Open ();
				conn.tds.Execute (String.Format ("sp_password '{0}', '{1}', '{2}'",
								 conn.parms.Password, newPassword, conn.parms.User));
			}
		}