What is the root cause of this error?
Exception in aiSettings.get_setting():
CoreLab.PostgreSql.PgSqlException: CONNECTION FAILURE
at CoreLab.PostgreSql.PgSqlConnection.b()
at CoreLab.PostgreSql.PgSqlConnection.Open()
at aiSettings.get_setting(String setting) in c:\Inetpub\wwwroot\MDRDEV-AIMS\aims_simcoe\App_Code\common\aiSettings.cs:line 54
Ignore the class name and all that, it's a very basic database call - this happens in several of my applications that I use the CoreLab driver (3.25) with at random times. If I refresh the page a few times eventually it comes back again.
Checking the server, Postgres is running fine and so is IIS - anyone else run into this?
Here's the way I'm calling to the database as a general rule, again it's not just this function, it's several, this is just an easy example.
Code: Select all
public static String get_setting(String setting) {
try {
using (PgSqlConnection conn = new PgSqlConnection(ConfigurationManager.ConnectionStrings["cs_aims"].ToString())) {
String query = "SELECT value " +
"FROM ai_tbl_settings " +
"WHERE setting=?";
PgSqlCommand cmd = new PgSqlCommand(query, conn);
cmd.Parameters.Add("setting", setting);
conn.Open();
return cmd.ExecuteScalar().ToString();
}
} catch (Exception e) {
aiLog.error("Exception in aiSettings.get_setting():" + System.Environment.NewLine + e.ToString());
return "";
}
}