C# 使用C和Access数据库的报表查看器

C# 使用C和Access数据库的报表查看器,c#,database,ms-access,report,reportviewer,C#,Database,Ms Access,Report,Reportviewer,我想在数据库访问中检索某个表中的一些数据,但每次从数据库检索数据时,它只会在其中提供一个空白数据。为了更详细,这里是我的代码 private void simpleButton1_Click_1(object sender, EventArgs e) { if (cboSearch.Text == "ALL") { DataTable dt = new DataTable(); try

我想在数据库访问中检索某个表中的一些数据,但每次从数据库检索数据时,它只会在其中提供一个空白数据。为了更详细,这里是我的代码

private void simpleButton1_Click_1(object sender, EventArgs e)
    {
        if (cboSearch.Text == "ALL")
        {
            DataTable dt = new DataTable();
            try
            {
                OleDbConnection Con = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=..\\MotoFix.mdb");

                OleDbCommand Com = new OleDbCommand();
                OleDbDataAdapter adapter = new OleDbDataAdapter();
                Con.Open();
                Com.Connection = Con;

                if (true)
                {
                    Com.CommandText = String.Format("SELECT prodCode as [Code], prodName as [Name], prodDescription as [Description], prodBrand as [Brand], prodSRP as [Product Price], sCategory as [Category] FROM Product");
                    adapter.SelectCommand = Com;
                    adapter.Fill(dt);
                }

                this.productBindingSource.DataSource = dt; 
                this.reportViewer1.RefreshReport(); 
                Con.Close();
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
    }

不要这样做:扔掉前男友;这将删除有价值的信息。如果要再次抛出异常,请使用throw;只显示或忽略catch块。它仍然是一样的,它仍然不显示任何记录:DDid您调试它了吗?数据表中有什么?您的SQL生成数据了吗?是的!我的表的名称是Product,其中有许多值:howeare this.productBindingSource.DataSource=dt;以及这个.reportViewer1.RefreshReport;有联系的?你有任何有效的报告吗,还是你的第一份?