3 pièce(s) jointe(s)
bizarrerie dans tri dans combobox?
bonjour a tous,
je rencontre un probleme de tri dans une combobox, j'ai beau cherché, je ne trouve pas l'erreur ... pourtant je suis sure que j'ai le nez dessus :mouarf:
voila mon code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' Chemin de l'éxécutable
Dim exepath As String = Environment.GetCommandLineArgs()(0) ' Pour les WinForm, on peut aussi utiliser Application.ExecutablePath
exedir = exepath.Substring(0, exepath.LastIndexOf("\")) ' Répertoire de l'executable
' remplie le ComboBox
Mycommand.CommandText = "SELECT table_programmateur.id FROM table_programmateur"
MyConnexion.Open()
Dim myReader As OleDbDataReader = Mycommand.ExecuteReader()
Do While myReader.Read()
ComboBox1.Items.Add(myReader.GetString(0))
Loop
myReader.Close()
MyConnexion.Close()
'selectionne le premier element de la combobox
ComboBox1.SelectedIndex = 0
End Sub |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.Text <> "System.Data.DataRowView" Then ' charge le choix si on est pas au debut du form et que les valeurs sont définis
Dim MyConnexion As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & exedir & "\mabase.mdb;")
Dim Mycommand As OleDbCommand = MyConnexion.CreateCommand()
Mycommand.CommandText = "SELECT value1,value2,value3 FROM table_programmateur WHERE id = '" & ComboBox1.Text & "'" 'retourne la valeur correspondante a l'id choisi
MyConnexion.Open()
Dim myReader As OleDbDataReader = Mycommand.ExecuteReader()
myReader.Read()
TextBox1.Text = myReader.GetString(0) 'affecte la valeur au textbox correspondant
TextBox2.Text = myReader.GetString(1)
TextBox3.Text = myReader.GetString(2)
myReader.Close()
MyConnexion.Close()
End If
End Sub |
une copie de ma table
http://www.developpez.net/forums/att...1&d=1323952574
lorsque j'execute la requete de chargement (au debut du form) directement dans la table, j'ai bien les valeurs dans l'ordre de la table
http://www.developpez.net/forums/att...1&d=1323952757
pourtant dans le form,ca melange tout :cry:
http://www.developpez.net/forums/att...1&d=1323952834
j'ai pas l'impression qu'il y'a des caracteres cachés... :oops:
bizarrement j'ai une autre combobox et j'utilise la meme methode et dans le 2eme combobox , ca marche :calim2: