How to connect to PostgreSQL database from C# application?

The application connect using NPGSQL
connectionStr = $"Server=localhost;Port=1488;User={LoginText.Text.Trim(' ')};Password={PasswordText.Text.Trim(' ')};Database=PrivateBD;";
npgSqlConnection = new NpgsqlConnection(connectionStr);
try
{
npgSqlConnection.Open();
MessageBox.Show("Connection ustanovleno! ", "Cheers", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
And then gives an error that the base that I mentioned in the line does not exist!
Severity: FATAL Code: 3D000
But this same string only with the base under the name postgres sets the connection to cheer. What could be the problem? Error appears on any created by me in pdAdmin database!
July 9th 19 at 11:21
1 answer
July 9th 19 at 11:23
Move the connection string in the config file, also check the user in the specified database can help.

Find more questions by tags C#PostgreSQLSQL