Please i want to creat a Database if not exist, and after if the Database exist i want to creat tables.
I use this code :
using Npgsql;
string server = "localhost";
string database = "MyNewDatabase";
string password = "password1234";
string connectionString = @"Server=" + server + ";User Id=postgres; Password=" + password + ";";
var connection = new NpgsqlConnection(connectionString);
string commandText = string.Format("CREATE DATABASE IF NOT EXISTS \"{0}\";", database);
var command = new NpgsqlCommand(commandText);
connection.Open();
command.Connection = connection;
command.ExecuteNonQuery();
connection.Close();
the problem is i get a error : 42601
(syntax error using « NOT »).
Using C#
, i am trying to verify if the database exist, if not we will creat it, and after we will verify if the tables exist, if they not exist we will creat them.
Please, may someone tell me how to do it?
Thanks stackoverflowers