Bonjour à tous!
J'ai un form avec un Datagridview issu d'un TableAdapter de plusieurs tables,et sur ce form j'ai mis trois textbox1,2,3 : Matricule,Nom,Prénom
J'aimerais faire un filtrage au choix de ces trois textbox en cliquant sur un bouton "Recherche"
Mon problème : quand je recense un textbox par exemple textBox1 Matricule,le datagridview se vide de données et n'affiche du coup rien du tout
Quelqu'un peut-il m'aider voici le code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 if (textBox1.Text.Length > 0) { SqlDataAdapter sda = new SqlDataAdapter("SELECT Employe.Matricule, Employe.Nom, Employe.Prenom, Statut.Corps, Statut.Cadre, Statut.Categorie, Statut.Grade, Statut.Echelon, Service.Service, Direction.Direction FROM Employe INNER JOIN Statut ON Employe.Matricule = Statut.Matricule INNER JOIN Service ON Employe.id_serv = Service.id_serv INNER JOIN Direction ON Service.id_dir = Direction.id_dir WHERE (Employe.Matricule = N' " + textBox1.Text + "%' ) AND (Employe.Nom = '" + textBox2.Text + "%') AND (Employe.Prenom = '" + textBox3.Text + "%')", con); sda.Fill(dt); DataGridView1.DataSource = dt; }
Partager