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 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| public void afficheGridView()
{
//string requete;
string message = "Problème lors de la connexion";
GridView monGridView = new GridView();
SqlDataSource gvSalarie = new SqlDataSource();
gvSalarie.ConnectionString = "Data Source=STQY-589\\SQLEXPRESS; Initial Catalog=DossierIndividuel;Integrated Security=True";
gvSalarie.SelectCommand = "SELECT nomSociete, libellePere, nomGroupeAgence, nomAgence, intituleCategorie, TABLEAU.matricule, nomPrenomSalarie, typeDocument " +
"FROM TABLEAU, SALARIE " +
"WHERE SALARIE.matriculeRh = '7R777' " +
"AND SALARIE.matricule = TABLEAU.matricule";
//SqlConnection connexion = new SqlConnection("Data Source=STQY-589\\SQLEXPRESS; Initial Catalog=DossierIndividuel;Integrated Security=True");
try
{
/*if (connexion.State == ConnectionState.Closed)
{
connexion.Open();
}
requete = "SELECT nomSociete, libellePere, nomGroupeAgence, nomAgence, intituleCategorie, TABLEAU.matricule, nomPrenomSalarie, typeDocument " +
"FROM TABLEAU, SALARIE " +
"WHERE SALARIE.matriculeRh = '7R777' " +
"AND SALARIE.matricule = TABLEAU.matricule";
// Exécution de la requête et affichage du GridView
SqlCommand commande = new SqlCommand(requete, connexion);
SqlDataAdapter sqlDA = new SqlDataAdapter(commande);
DataSet ds = new DataSet();
sqlDA.Fill(ds);
gvSalarie.DataSource = ds;
gvSalarie.DataBind();
EnableViewState = true;
commande.Dispose();
connexion.Close()*/
monGridView.DataSource = gvSalarie;
monGridView.DataBind();
}
catch (Exception ex)
{
Outil.Message(message, this);
//Console.WriteLine(ex);
}
} |
Partager