Hi,
I am facing FATAL: sorry, too many clients already in postgresql-12.
I need advice about database connection, does my code below already close the database connection properly?
I am facing FATAL: sorry, too many clients already in postgresql-12.
I need advice about database connection, does my code below already close the database connection properly?
Code:
try
{
using (NpgsqlConnection _conn = new NpgsqlConnection(Models.AppSettings.Application.PG_SQL.Connection_String))
{
try
{
string _sql = "Select * From mytable";
var _dr = await _conn.ExecuteReaderAsync(_sql, new { });
if (_dr.HasRows)
{
while (await _dr.ReadAsync())
{
}
}
}
catch (Exception ex) { ..... }
finally { }
}
}
catch (Exception ex) { .... }
finally { }