我想在RDLC报告中显示新列“Total”, 实际上,用于计算总数的字段是不同的数据集。 我创建了一个数据表,并将要在报告中显示的字段(包括“total”)插入其中。 当我执行程序时,错误显示“关键字'WHERE'附近的语法不正确。
string sql = "SELECT customer.customer,
customer.imp_license_no,
customer.psq_level,
whbal.std_weight,
whbal.qty_good,
whbal.qty_slack,
total FROM (
SELECT((qty_good+qty_slack)*std_weight/1000) AS Total FROM whbal
WHERE warehouse='SKW') customer
INNER JOIN whbal
WHERE customer.customer=whbal.customer AND customer.customer BETWEEN @cust1 AND @cust2";
SqlCommand custcom = new SqlCommand(sql, myconnection);
custcom.Parameters.AddWithValue("@cust1", cboFrom.SelectedValue.ToString());
custcom.Parameters.AddWithValue("@cust2", cboTo.SelectedValue.ToString());
SqlDataAdapter da = new SqlDataAdapter(custcom);
DataSet1 ds = new DataSet1();
da.Fill(ds, "customer1");
da.Fill(ds, "whbal");
myconnection.Close();
reportViewer1.Reset();
reportViewer1.LocalReport.ReportEmbeddedResource = "WindowsFormsApplication1.Report1.rdlc";
reportViewer1.ProcessingMode = ProcessingMode.Local;
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", ds.Tables["Customer1"]));
reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1",ds.Tables["whbal"]));
reportViewer1.RefreshReport();
有谁知道这是什么问题,请帮助评论。 提前致谢
答案 0 :(得分:6)
您不应该将ON
用于INNER JOIN
吗?
INNER JOIN whbal ON customer.customer = whbal.customer AND
customer.customer BETWEEN @cust1 AND @cust2";