SqlCommand c = new SqlCommand(); c.CommandText "SELECT * FROM Date WHERE 'date_vérification_étalonnage' @DateVerif"; // Il ne faut rien mettre autour de @DateVerif (ni ', ni #). // Ce sera ajouté automatiquement selon le type de variable que tu donnes. DateTime dateVerif = DateTime.Now; // Bien sûr, tu mets la valeur que tu veux c.Parameters.Add(new SqlParameter("@DateVerif", dateVerif)); adap.SelectCommand = c;
c.CommandText "SELECT * FROM Date WHERE Year(date_vérification_étalonnage) @Annee"; c.Parameters.Add(new SqlParameter("@Annee", 2010));
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionx.Tables.Clear(); // x.Tables[0].Clear(); // StyleDtg(); SqlConnection con = new SqlConnection("............"); SqlDataAdapter adap = new SqlDataAdapter(); adap.SelectCommand = new SqlCommand("select *from Date where Year (date_vérification_étalonnage)='" + 2012 + "'", Program.con); adap.Fill(x); dataGridView1.DataSource = x.Tables[0];
SqlConnection con = new SqlConnection("..."); SqlDataAdapter adap = new SqlDataAdapter(); SqlCommand c new SqlCommand("SELECT * FROM Date WHERE Year(date_vérification_étalonnage) @Annee"); c.Parameters.Add(new SqlParameter("@Annee", 2010)); c.Connection = con; adap.SelectCommand = c;
SqlConnection con = new SqlConnection("..."); SqlDataAdapter adap = new SqlDataAdapter(); SqlCommand c = new SqlCommand("SELECT * FROM Date WHERE date_vérification_étalonnage BETWEEN @DateDebut AND @DateFin); c.Parameters.Add(new SqlParameter("@DateDebut", new DateTime(2010, 1, 1))); c.Parameters.Add(new SqlParameter("@DateFin", new DateTime(2011, 1, 1))); c.Connection = con; adap.SelectCommand = c;