OpenWithNewPasswordAsync(String)
This method opens a new connection asynchronously with a new password.
Declaration
// C# public Task OpenWithNewPasswordAsync(string newPassword);
Parameters
-
newPasswordA string that contains the new password.
Return Value
Task object representing the asynchronous operation immediately without blocking the calling thread for the whole duration of opening connection.
Remarks
This method uses the ConnectionString property settings to establish a new connection. The old password must be provided in the connection string as the Password attribute value.
This method can only be called on an OracleConnection in the closed state.
Example
namespace AsyncApp
{
class AsyncDemo
{
static async Task Main()
{
//Specify old password in connection string
string connectionString = "User Id=HR; Password=<PASSWORD>; Data Source=oracle;";
OracleConnection oc = new OracleConnection(connectionString);
String newPass = "newPass";
// Open a connection asynchronously with new password
Task task = oc.OpenWithNewPasswordAsync(newPass);
// Execute an operation while the connection is being opened asynchronously
Console.WriteLine("Opening a connection asynchronously.");
// wait for the connection to be opened
await task;
Console.WriteLine("Connection opened successfully, password changed to " + newPass);
oc.Close();
}
}
}