0

RDLCレポートに新しい列「合計」を表示したいのですが、実際には合計を計算するために使用するフィールドは別のデータセットです。データ テーブルを作成し、レポートに表示するフィールド (「合計」を含む) を挿入しました。プログラムを実行すると、「キーワード '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();

問題が何かを知っている人はいますか? plsはコメントするのに役立ちます. 前もって感謝します

4

1 に答える 1

6

ONに使用するべきではありませんINNER JOINか?

INNER JOIN whbal ON customer.customer = whbal.customer AND 
                    customer.customer BETWEEN @cust1 AND @cust2";
于 2013-10-30T03:09:03.073 に答える