Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

probleme de Recherche MultiCritere avec DataSet

1 réponse
Avatar
FredericThomas
Bonjour a tous

Voici plusieurs jours que je peine pour realiser une recherche multicriere
dans un DataSet.

Mes tests ce base sur trois tables:

J'ai monter mon DataSet de la facon suivante:

une table TYPE avec comme clé primaire NumType
une table THEME avec comme clé primaire NumTheme
Une table BIEN avec comme clé primaire NumBien et deux clé etrangères
NumType et NumTheme

Une DataRelation TypeBien
Une DataRelation ThemeBien

Dans mon formulaire j'ai 2 ComboBox et un listbox

Une ComboBox pour la table Type
Une ComboBox pour la table Theme

Un ListBox pour la table Bien

J'exploite le resultat de cette facon

Le code
Private Sub ComboBox_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cbType.SelectedIndexChanged,
cbTheme.SelectedIndexChanged
Dim dr As DataRow
If cbTheme.SelectedIndex <> -1 Then
Dim IntTheme As Integer = cbTheme.SelectedIndex
Dim drTheme As DataRow
Dim drBien() As DataRow
Try
drTheme = ds.Tables("Theme").Rows(IntTheme)
drBien = drTheme.GetChildRows("ThemeBien")
Label1.Text = drBien.Length.ToString & " Référence(s)"
ListBox1.Items.Clear()
For Each drTheme In drBien
ListBox1.Items.Add(drTheme("NumBien"))
Next
Catch ex As Exception
MessageBox.Show(ex.Message & ex.Source)
End Try
End If

If cbType.SelectedIndex <> -1 Then
Dim IntType As Integer = cbType.SelectedIndex
Dim drType As DataRow
Dim drBien() As DataRow
Try
drType = ds.Tables("Type").Rows(IntType)
drBien = drType.GetChildRows("TypeBien")
Label1.Text = drBien.Length.ToString & " Référence(s)"
ListBox1.Items.Clear()
For Each drType In drBien
ListBox1.Items.Add(drType("NumBien"))
Next
Catch ex As Exception
MessageBox.Show(ex.Message & ex.Source)
End Try
End If
End Sub

Mon Probleme est que je n'arrive pas effectuer un resultat multicritere.

1 réponse

Avatar
Zoury
Salut Frédéric ! :O)

Voici plusieurs jours que je peine pour realiser une recherche multicriere
dans un DataSet.

Mes tests ce base sur trois tables:


<snip>
J'exploite le resultat de cette facon



Pourquoi ne pas employer le Databinding et laisser les contrôles faire le
travail ?


Mon Probleme est que je n'arrive pas effectuer un resultat multicritere.



Si tu souhaites le réaliser les



J'ai monter mon DataSet de la facon suivante:

une table TYPE avec comme clé primaire NumType
une table THEME avec comme clé primaire NumTheme
Une table BIEN avec comme clé primaire NumBien et deux clé etrangères
NumType et NumTheme

Une DataRelation TypeBien
Une DataRelation ThemeBien

Dans mon formulaire j'ai 2 ComboBox et un listbox

Une ComboBox pour la table Type
Une ComboBox pour la table Theme

Un ListBox pour la table Bien


Le code
Private Sub ComboBox_SelectedIndexChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles cbType.SelectedIndexChanged,
cbTheme.SelectedIndexChanged
Dim dr As DataRow
If cbTheme.SelectedIndex <> -1 Then
Dim IntTheme As Integer = cbTheme.SelectedIndex
Dim drTheme As DataRow
Dim drBien() As DataRow
Try
drTheme = ds.Tables("Theme").Rows(IntTheme)
drBien = drTheme.GetChildRows("ThemeBien")
Label1.Text = drBien.Length.ToString & " Référence(s)"
ListBox1.Items.Clear()
For Each drTheme In drBien
ListBox1.Items.Add(drTheme("NumBien"))
Next
Catch ex As Exception
MessageBox.Show(ex.Message & ex.Source)
End Try
End If

If cbType.SelectedIndex <> -1 Then
Dim IntType As Integer = cbType.SelectedIndex
Dim drType As DataRow
Dim drBien() As DataRow
Try
drType = ds.Tables("Type").Rows(IntType)
drBien = drType.GetChildRows("TypeBien")
Label1.Text = drBien.Length.ToString & " Référence(s)"
ListBox1.Items.Clear()
For Each drType In drBien
ListBox1.Items.Add(drType("NumBien"))
Next
Catch ex As Exception
MessageBox.Show(ex.Message & ex.Source)
End Try
End If
End Sub

Mon Probleme est que je n'arrive pas effectuer un resultat multicritere.