I am trying to connect a PostgreSQL database to a C# console app. This is my code:
static void Main(string[] args)
{
string connstring = String.Format("Server=localhost;Port=5432;" +
"User Id=postgres;Password=admin;Database=mydb;");
NpgsqlConnection conn = new NpgsqlConnection(connstring);
conn.Open();
string sql = string.Format("CREATE TABLE public.stvari2 ime text, broj smallint, id integer)");
NpgsqlCommand cmd = new NpgsqlCommand(sql, conn);
cmd.ExecuteNonQuery();
}
I literally copied the the reverse-engineered SQL query from Postgres, so I doubt that that's the problem. Anyhow, when I run it I get an exception:
An unhandled exception of type 'Npgsql.PostgresException' occurred in Npgsql.dll
at the last line (executeNonQuery). Any ideas?