Bonjour a tous

Je suis entrain de faire un gestion d'un stock avec une base de donnees sql server

j'ai une table dans sql = produit avec des attribut Nproduit , stock

j'ai fait un text label qui change selon le choix du combobox



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
19
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string s = ;
            string str = "Data source = localhost;initial catalog =stock;integrated security=true";
            string sql = "Select stock from produit where Nproduit = Convert.ToString( comboBox1.SelectedItem) ";
            SqlConnection oCon = new SqlConnection(str);
            oCon.Open();
            SqlCommand oCom = new SqlCommand(sql, oCon);
            SqlDataReader Dr;
            
            Dr = oCom.ExecuteReader();

            while (Dr.Read())
            {
                label6.Text=(Dr[0].ToString());
            }
            oCon.Close();
            
        }
le probleme est dans la partie souligné