From 5b996f98f0b9b7f056af29977de0ff93fb3a6a4c Mon Sep 17 00:00:00 2001 From: nimaye Date: Mon, 17 Oct 2022 09:49:12 +0200 Subject: [PATCH] gestion de l'exception --- Code/LinqToPgSQL/PersLinqToPgSQL.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Code/LinqToPgSQL/PersLinqToPgSQL.cs b/Code/LinqToPgSQL/PersLinqToPgSQL.cs index 9c5d4c6..ccaad1d 100644 --- a/Code/LinqToPgSQL/PersLinqToPgSQL.cs +++ b/Code/LinqToPgSQL/PersLinqToPgSQL.cs @@ -32,8 +32,17 @@ namespace LinqToPgSQL List ListeInscrits = new List(); var conn = new NpgsqlConnection(connString); - Console.Out.WriteLine("Ouverture de la connection"); - conn.Open(); + Console.Out.WriteLine("Ouverture de la connection"); try + { + conn.Open(); + } + catch + { + conn.Close(); + Environment.Exit(0); + + } + var AllInscrit = new NpgsqlCommand("SELECT * FROM Inscrit", conn);