B
B
beduin012016-04-19 15:32:15
PostgreSQL
beduin01, 2016-04-19 15:32:15

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;");

How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stanislav Makarov, 2016-04-19
@Nipheris

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 question

Ask a Question

731 491 924 answers to any question