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
| private void Frmlienclasse_Load(object sender, EventArgs e)
{
try
{
connexion.ConnectionString = "Data Source=Baptiste-PC;Initial Catalog=GestionNotes;User=sa;Password=info";
connexion.Open();
string strRequete;
strRequete = "Exec afficherclasse";
SqlCommand pCommand = new SqlCommand(strRequete, connexion);
SqlDataReader pMyExecut = default(SqlDataReader);
pMyExecut = pCommand.ExecuteReader();
while (pMyExecut.Read())
{
//CBclasse.DataSource = ;
CBclasse.ValueMember = pMyExecut[0].ToString();
CBclasse.DisplayMember = pMyExecut[2].ToString();
}
pMyExecut.Close();
connexion.Close();
}
catch (Exception ex)
{
MessageBox.Show("Echec du chargement " + ex.Message);
connexion.Close();
}
} |