Access 内部または C# から OleDbCommand として機能する次のクエリがあります。
SELECT Table1.ProductType, Sum(Table1.ProductsSold)
FROM Table1
WHERE (Table1.DateTime Between #5/16/2013# And #5/17/2013#)
GROUP BY Table1.ProductType;
Table1.DateTime は日付/時刻データ型です。
ここで、日付を OleDbParameters として渡したいと思います。
SELECT Table1.ProductType, Sum(Table1.ProductsSold)
FROM Table1
WHERE (Table1.DateTime Between #@StartDate# And #@StopDate#)
GROUP BY Table1.ProductType;
cmd.Parameters.Add(new OleDbParameter("@StartDate", OleDbType.Date));
cmd.Parameters["@StartDate"].Value = dateTimePicker1.Value.ToShortDateString();
cmd.Parameters.Add(new OleDbParameter("@StopDate", OleDbType.Date));
cmd.Parameters["@StopDate"].Value = dateTimePicker2.Value.ToShortDateString();
私は多くのことを検索して試しました (VarChar と文字列、ハッシュタグの代わりの一重引用符、コマンドまたはパラメーターのハッシュタグなど)。日付を真夜中に開始したい (したがって、ToShortDateString() および Date 型)。