Crystal reports 对象引用未设置为对象的实例c#Mysql->;数据集->;晶体报告

Crystal reports 对象引用未设置为对象的实例c#Mysql->;数据集->;晶体报告,crystal-reports,dataset,Crystal Reports,Dataset,我正在尝试将我的数据从MySqlDatabase显示到我的CrystalReport。我尝试了不同的方法,但仍然得到错误“对象引用未设置为对象的实例” 我将我的数据集命名为ReportDataSet,我还创建了一个与我的MySqlDatabase名称、内容和数据类型完全相同的表 MySqlConnection connection; MySqlCommand command; MySqlDataReader reader; MySq

我正在尝试将我的数据从
MySqlDatabase
显示到我的
CrystalReport
。我尝试了不同的方法,但仍然得到错误“对象引用未设置为对象的实例”

我将我的
数据集
命名为ReportDataSet,我还创建了一个与我的MySqlDatabase名称、内容和数据类型完全相同的表

        MySqlConnection connection;
        MySqlCommand command;
        MySqlDataReader reader;
        MySqlDataAdapter adapter;
        string con = "";

        private void report_Load(object sender, EventArgs e)
        {
            con = "Server = localhost; Database = sample_inventory; Uid = root";
            connection = new MySqlConnection(con);
            connection.Open();

        }
        private void button1_Click(object sender, EventArgs e)
        {

            try
            {

                command = connection.CreateCommand();
                command.CommandText = "select * from tbl_account";
                adapter = new MySqlDataAdapter();
                adapter.SelectCommand = command;
                ReportDataSet ds = new ReportDataSet();
                ds.Clear();
                adapter.Fill(ds, "tbl_account");

                // Create a CrystalReport1
                CrystalReport1 myReport = new CrystalReport1();
                // Set the DataSource 
                myReport.SetDataSource(ds);
                // Report Source to ReportView 
                crystalReportViewer1.ReportSource = myReport; 
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }

错误发生在哪里?我一执行按钮,就在代码的何处单击事件?