【发布时间】:2015-06-16 14:18:06
【问题描述】:
我有 3 个表:供应商、账单和付款。每个供应商都有付款和账单。我想检索这样的报告:
供应商名称 |总账单 |总付款|余额
对于由 2 DateTimePickers 指定的特定时间段。
这是我的 SQL 查询:
OleDbCommand cmd = new OleDbCommand("select c.sup_Name,c.sup_Place,sum(a.bill_Total),sum(d.pa_Value)
from (suppliers c left JOIN bills a
on c.sup_Id = a.bill_From)
left join payments d on c.sup_Id = d.pa_To
where (a.bill_Date >= '" + txbFrom.Text + "' and a.bill_Date <= '" + txbTo.Text + "') and (d.pa_EntryDate >= '" + txbFrom.Text + "' and d.pa_EntryDate <= '" + txbTo.Text + "')
group by c.sup_Name,c.sup_Place order by c.sup_Name asc", objConn);
OleDbDataReader dataReader = cmd.ExecuteReader();// Here the error appear.
【问题讨论】:
-
使用参数化查询,但我很确定 MSAccess 中的日期应该用
#分隔,而不是 '。 -
您可以提供更多信息吗?
-
@ValAsensio ,我为关系添加了一张图片
-
@RonBeyer,对不起,我说不是,但它有效:D .. (y)