How to use Crystal Reports without a tightly-linked DB connection?

前端 未结 2 1071
悲&欢浪女
悲&欢浪女 2020-12-19 15:16

I\'m learning to use Crystal Reports (with VB 2005).

Most of what I\'ve seen so far involves slurping data directly from a database, which is fine if that\'s all you

2条回答
  •  心在旅途
    2020-12-19 16:05

    Go ahead and create the stock object as described in the link you posted and create the report (StockObjectsReport) as they specify. In this simplified example I simply add a report viewer (crystalReportViewer1) to a form (Form1) and then use the following code in the Form_Load event.

    stock s1 = new stock("AWRK", 1200, 28.47);
    stock s2 = new stock("CTSO", 800, 128.69);
    stock s3 = new stock("LTWR", 1800, 12.95);
    
    ArrayList stockValues = new ArrayList();
    
    stockValues.Add(s1);
    stockValues.Add(s2);
    stockValues.Add(s3);
    
    ReportDocument StockObjectsReport = new StockObjectsReport();
    StockObjectsReport.SetDataSource(stockValues);
    
    crystalReportViewer1.ReportSource = StockObjectsReport;
    

    This should populate your report with the 3 values from the stock object in a Windows Form.

    EDIT: Sorry, I just realized that your question was in VB, but my example is in C#. You should get the general idea. :)

提交回复
热议问题