0

C# Web アプリケーションで Crystal Report を使用しています。Crystal レポートが For ループから最後のレコードをロードするという問題があります。

i は、コードとして for ループに product のコードを格納します。そして、その単一または複数のコードに従って、クリスタルレポートに情報が表示されます。その製品の。

私が使う....

for (int i = 0; i < code.Length; i++)
    {
        string str = "select crbal*-1 as crbal, glname, contprsn, refby, glphone1, glcity, glphone2, email, crlimit, restorddueamt  from db1.dbo.glmast WHERE drgroup='A3402' and crbal<>0 and glcode="+code[i]+ "";

        SqlDataAdapter ad = new SqlDataAdapter(str, con2);
        DataSet ds = new DataSet();
        ad.Fill(ds);

        path = Server.MapPath("ERP_REPORT_MAIN.rpt");
        cr = new ReportDocument();
        cr.Load(path);

        cr.SetDataSource(ds.Tables[0]);
        CrystalReportViewer1.ReportSource = cr;
    }

for ループに 2 つのコードがある場合、最後のレコードのみを表示します。私を助けてください。

よろしくお願いします... Mitesh

4

1 に答える 1

0

コードを修正し、効率を少し改善します。

string query = "select crbal*-1 as crbal, glname, contprsn, refby, glphone1, glcity,    glphone2, email, crlimit, restorddueamt  from db1.dbo.glmast WHERE drgroup='A3402' and crbal<>0 and glcode in (

for (int i = 0; i < code.Length; i++)
{
    query += code[i];
    if (i != code.Length -1)
        query += ","
    else
        query += ")";
}

SqlDataAdapter ad = new SqlDataAdapter(str, con2);
DataSet ds = new DataSet();
ad.Fill(ds);

path = Server.MapPath("ERP_REPORT_MAIN.rpt");
cr = new ReportDocument();
cr.Load(path);

cr.SetDataSource(ds.Tables[0]);
CrystalReportViewer1.ReportSource = cr;
于 2012-06-21T07:35:18.413 に答える