Bonjour,
J'ai essayé de remplir un combobox à partir de ma base de données mais j'ai obtenu cet erreur. Comment je peux résoudre ce problème SVP?
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in MySql.Data.dll
Additional information: Could not find specified column in results: categoriemerci d'avance
Code : 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 Private Sub Form5_Load(sender As Object, e As EventArgs) Handles MyBase.Load Dim conn As New MySqlConnection("SERVER=localhost; uid =root;DATABASE =stock;PASSWORD =;") Dim cmd As MySqlCommand Dim rd As MySqlDataReader Try conn.Open() Dim Sql = "SELECT * FROM clients" cmd = New MySqlCommand(Sql, conn) rd = cmd.ExecuteReader While rd.Read Dim cat = rd.GetString("categorie") ComboBox1.Items.Add(cat) End While conn.Close() Catch ex As MySqlException MessageBox.Show(ex.Message) End Try End Sub
Partager