samedi 9 mai 2015

combobox: Parameter @code1 has no default value. vb.net

I'm creating this code to use two combobox that one of them depend to the first but when i'm trying to select the "code_Zone" from the Table "Zone" i have this exception "Parameter @code1 has no default value"
this is my code:

![combobox code]
Dim cmd3 = New OleDbCommand("select [Code_Zone] from [Zone] where [Nom_Zone]= '@code';", connection)
            cmd3.Parameters.AddWithValue("@code", ComboBoxNomZoneDeclaration.SelectedText.ToString)
            Dim valeur = cmd3.ExecuteScalar
            Dim commande = New OleDbCommand("select [Code_Cable] from [CableEnFibre] where [Code_Zone]=@code1;", connection)
            commande.Parameters.AddWithValue("@code1", valeur)
            Dim reader = commande.ExecuteReader   'there is the exception 
            While reader.Read
                ComboBoxPanneCentreAppel.Items.Add(reader.GetInt32(reader.GetOrdinal("Code_Cable")))
            End While
            reader.Close()

Aucun commentaire:

Enregistrer un commentaire