开发者

Passing SQL to Crystal Report

I was just wondering how to pass SQL t开发者_如何学运维o crystal report. Right now I am only able to load a premade report onto my crystal report viewer. Now, I want to be able to put in parameters for building my reports. Here's some code...

    private void btn_InventoryReport_Click_1(object sender, EventArgs e)
    {
        ReportDocument inventoryReport = new ReportDocument();
        inventoryReport.Load("C:\\Users\\Wilson Kao\\documents\\visual studio 2010\\Projects\\Wincent Warehouse Management Studios\\Wincent Warehouse Management Studios\\InventoryReport.rpt");
        inventoryReport.Refresh();
        crv_Report.ReportSource = inventoryReport;
        crv_Report.Refresh();
    }

Right now, I want to be able to add SQL to filter out the report, something like this

da.SelectCommand = new OleDbCommand("SELECT * FROM InventoryView WHERE vid = @vid", cs);
da.SelectCommand.Parameters.Add("@vid", OleDbType.Integer).Value = vid;
//Make Report Based on this SQL

I tried this : http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-sql-query.htm

but it said i'm missing an assembly or something like that (prob a 64/32 bit incompatibility) but hopefully theres something else I can do. Thanks!


That sample code link specifies the following:

You have to include CrystalDecisions.CrystalReports.Engine in your C# Source Code.

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared; 

This means that in your project's references you have to have the CrystalDecisions.CrystalReports.Engine assembly which you need to import manually. E.g. right click on References and select Add Reference then either choose the assembly from the list or navigate to it on disk.


Solved. Looked into the bug and it said that I actually needed to move some of the dlls into something called dotnet1 folder (it wasnt there I had to create it myself). After that I had to modify app.config and it worked. awesome

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜