Bonjour,
Je me gratte la tète sur récupérer une combobox avec string qui prend 2 valeurs pour afficher une valeur dans un textbox.
Le Premier code m'affiche clairement ce que je desire.

Code vb.net : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 'INICIO PRODUCTO
        Try
            MysqlConn.Open()
            Dim Query As String
            Query = "select Apellidos, Nombre from test.RHumanos_Personal order by Apellidos asc"
            COMMAND = New MySqlCommand(Query, MysqlConn)
            READER = COMMAND.ExecuteReader
            While READER.Read
                Dim Apellidos = READER.GetString("Apellidos")
                Dim Nombre = READER.GetString("Nombre")
                ComboBox1.Items.Add(String.Format("{0} | {1}", Apellidos, Nombre))
            End While
 
            MysqlConn.Close()
 
        Catch ex As MySqlException
            MessageBox.Show(ex.Message)
            MysqlConn.Dispose()
        Finally
            MysqlConn.Dispose()
 
        End Try
        'FIN PRODUCTO

Donc je peux choisir en voyant Apellidos et Nombre. Jusqu'ici pas de problemes.

C'est la deuxième parti du code qui me pose problème. Si je n'avais qu'une valeur je n'aurai pas eu le problèmes. Au moment de cliquer je crois qu'il c'est pas lire le combobox du au string.

Code vb.net : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
 
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
 
        MysqlConn = New MySqlConnection
        MysqlConn.ConnectionString =
        "server=localhost;userid=root;password=root;database=test"
        Dim READER As MySqlDataReader
 
        Try
            MysqlConn.Open()
            Dim Query As String
            Query = "select Direccion from test.RHumanos_Personal where Apellidos  = '" & ComboBox1.Text & "' AND Nombre = '" & ComboBox1.Text & "'"
            COMMAND = New MySqlCommand(Query, MysqlConn)
            READER = COMMAND.ExecuteReader
            While READER.Read
                Dim Apellidos = READER.GetString("Apellidos")
                Dim Nombre = READER.GetString("Nombre")
                ComboBox1.Items.Add(String.Format("{0} | {1}", Apellidos, Nombre))
            End While
 
 
            While READER.Read
                TextBox1.Text = READER.GetString("Direccion")
 
            End While
 
            MysqlConn.Close()
 
        Catch ex As MySqlException
            MessageBox.Show(ex.Message)
        Finally
            MysqlConn.Dispose()
 
        End Try

Je laisse le code en entier si quelqu'un peux m'aider a resoudre correctement ce probleme. Car je ne sais pas la correct syntax.


Code vb.net : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
 
Imports MySql.Data.MySqlClient
Public Class TEST
    Dim MysqlConn As MySqlConnection
    Dim COMMAND As MySqlCommand
    Private Sub TEST_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        MysqlConn = New MySqlConnection
        MysqlConn.ConnectionString =
        "server=localhost;userid=root;password=root;database=test"
        Dim READER As MySqlDataReader
 
        'INICIO PRODUCTO
        Try
            MysqlConn.Open()
            Dim Query As String
            Query = "select Apellidos, Nombre from test.RHumanos_Personal order by Apellidos asc"
            COMMAND = New MySqlCommand(Query, MysqlConn)
            READER = COMMAND.ExecuteReader
            While READER.Read
                Dim Apellidos = READER.GetString("Apellidos")
                Dim Nombre = READER.GetString("Nombre")
                ComboBox1.Items.Add(String.Format("{0} | {1}", Apellidos, Nombre))
            End While
 
            MysqlConn.Close()
 
        Catch ex As MySqlException
            MessageBox.Show(ex.Message)
            MysqlConn.Dispose()
        Finally
            MysqlConn.Dispose()
 
        End Try
        'FIN PRODUCTO
    End Sub
 
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
 
        MysqlConn = New MySqlConnection
        MysqlConn.ConnectionString =
        "server=localhost;userid=root;password=root;database=test"
        Dim READER As MySqlDataReader
 
        Try
            MysqlConn.Open()
            Dim Query As String
            Query = "select Direccion from test.RHumanos_Personal where Apellidos  = '" & ComboBox1.Text & "' AND Nombre = '" & ComboBox1.Text & "'"
            COMMAND = New MySqlCommand(Query, MysqlConn)
            READER = COMMAND.ExecuteReader
            While READER.Read
                Dim Apellidos = READER.GetString("Apellidos")
                Dim Nombre = READER.GetString("Nombre")
                ComboBox1.Items.Add(String.Format("{0} | {1}", Apellidos, Nombre))
            End While
 
 
            While READER.Read
                TextBox1.Text = READER.GetString("Direccion")
 
            End While
 
            MysqlConn.Close()
 
        Catch ex As MySqlException
            MessageBox.Show(ex.Message)
        Finally
            MysqlConn.Dispose()
 
        End Try
 
    End Sub
End Class


Merci de votre aide....