Answer the question
In order to leave comments, you need to log in
Specifying the database name in the connection string?
A question. I want to check whether it exists before connecting to the database. However, the connection string implies that you need to specify the name of the database to be used.
NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=admin;Database=XXXXXX;");
Answer the question
In order to leave comments, you need to log in
NpgsqlConnection conn = new NpgsqlConnection("Server=127.0.0.1;Port=5432;User Id=postgres;Password=admin;");
var databasesTable = conn.GetSchema("Databases", null);
// проверяем наличие базы данных в таблице databasesTable
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question