Connexion par ID et MDP fonctionnelle
continuous-integration/drone/push Build is passing Details

connexion
Lucas EVARD 2 years ago
parent 98c88e43bf
commit 75b6c7a2fd

@ -42,6 +42,7 @@ namespace IHM
private void test_Click(object sender, RoutedEventArgs e) private void test_Click(object sender, RoutedEventArgs e)
{ {
Manager.LoadInscrit("","");
testSelect(); testSelect();
/* testSuppression();*/ /* testSuppression();*/
} }

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Data;
using System.Configuration;
using Npgsql; using Npgsql;
using Model; using Model;
using System.IO; using System.IO;
@ -15,20 +17,26 @@ namespace LinqToPgSQL
string connexionBDD = String.Format("Server=90.114.135.116; Username=postgres; Database=conseco; Port=5432; Password=lulu; SSLMode=Prefer"); string connexionBDD = String.Format("Server=90.114.135.116; Username=postgres; Database=conseco; Port=5432; Password=lulu; SSLMode=Prefer");
public string LoadInscrit(string id, string mdp) public string LoadInscrit(string id, string mdp)
{ {
string resultat="";
var conn = new NpgsqlConnection(connexionBDD); var conn = new NpgsqlConnection(connexionBDD);
Console.Out.WriteLine("Ouverture de la connection"); Console.Out.WriteLine("Ouverture de la connection");
conn.Open(); conn.Open();
using var cmd = new NpgsqlCommand("SELECT id FROM INSCRIT WHERE (nom=(@p) OR mail=(@p)) AND mdp=@p2",conn) NpgsqlParameter p1 = new NpgsqlParameter { ParameterName = "p", Value = id };
NpgsqlParameter p2 = new NpgsqlParameter { ParameterName = "p2", Value = mdp };
NpgsqlCommand cmd = new NpgsqlCommand($"SELECT id FROM INSCRIT WHERE (nom=(@p) OR mail=(@p)) AND mdp=@p2", conn);
cmd.Parameters.Add(p1);
cmd.Parameters.Add(p2);
NpgsqlDataReader dr = cmd.ExecuteReader();
try
{ {
Parameters = dr.Read();
{ }
new("p", id), catch (Exception ex)
new("p2", mdp) { Console.Out.WriteLine("A GERER"); }
} dr.Close();
}; return null;
return cmd.ExecuteNonQuery().ToString();
} }
/*Revoir la BDD, probleme de clé étrangère de devise*/ /*Revoir la BDD, probleme de clé étrangère de devise*/

Loading…
Cancel
Save