I am getting the following database connection error in ASPM 2024 when I use Row Updated Event.
Please see my Code below
An unhandled exception occurred while processing the request.
SqlException: Cannot open database "{dbname}" requested by the login. The login failed.
Login failed for user 'myusername'.
Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, bool breakConnection, Action<Action> wrapCloseInAction)
SqlException: Cannot open database "{dbname}" requested by the login. The login failed. Login failed for user 'myusername'.
//Database Connecting event
public void Database_Connecting(ref string connstr) {
// Check Info["id"] for database ID if more than one database
connstr += "TrustServerCertificate=True;";
}
// Row Updated event
public void Row_Updated(Dictionary<string, object> rsold, Dictionary<string, object> rsnew) {
//Log("Row Updated");
string connString = Configuration.GetSection("Databases")["DB:connectionstring"];
string usrid = Configuration.GetSection("Databases")["DB:username"];
string password = Configuration.GetSection("Databases")["DB:password"];
connString = connString.Replace("{uid}", usrid).Replace("{pwd}", password);
connString += "TrustServerCertificate=True;";