数据未显示在数据库的水晶报表中

时间:2019-05-03 09:57:38

标签: c# winforms crystal-reports

我是水晶报告的初学者,出于测试目的,我制作了一份水晶报告。我正在使用数据库中的数据,但是运行winform后,它显示了空白的水晶报表。为什么?

winform中水晶报表的代码:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;

namespace WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-HKCVFM7;Initial Catalog=Testing;Integrated Security=True");

       //     SqlDataAdapter adp = new SqlDataAdapter();
            DataSet ds = new DataSet();
           SqlDataAdapter adp = new SqlDataAdapter("select * from Billdetails", con);
            adp.Fill(ds);
            ReportDocument rd = new ReportDocument();
            rd.Load(@"D:\WindowsFormsApplication4\WindowsFormsApplication4\CrystalReport1.rpt");
            rd.SetDataSource(ds);
            crystalReportViewer1.ReportSource = rd;

        }
    }
}

0 个答案:

没有答案