1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| private void TirageAuSort_Click(object sender, EventArgs e)
{
try
{
{
string sel = "SELECT TOP (" + this.nbgagnant.Text + ") nom_can, prenom_can, 1 as gagnant WHERE nom_can = '" + dataGridView1.CurrentCell + "' AND prenom_can = '" + dataGridView1.CurrentCell + "', FROM JeuxConcours.dbo." + this.Id2jeu.Text + " ORDER BY NEWID() ";
Console.Out.WriteLine(sel);
SqlConnection con = new SqlConnection("Data Source=*****;Initial Catalog=JeuxConcours;Persist Security Info=True;User ID=*****;Password=*****;");
SqlCommand cmd = new SqlCommand(sel, con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds, this.TitreJeu.Text);
dataGridView1.DataSource = ds.Tables[this.TitreJeu.Text];
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
} |