我查看了很多现有问题,但我的问题仍然存在。
我在reportViewer1
添加了MaisVendido.Form
,并在应用中添加了Report3.rdlc
,但此reportviewer
没有显示任何内容。为什么会这样?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Reporting.WinForms;
using System.Collections;
namespace Fabrication
{
public partial class MaisVendido : Form
{
DB db = new DB();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
public MaisVendido()
{
InitializeComponent();
Getdataset();
Getdatatable();
}
void Getdataset()
{
ds = db.ClientTable("select * from estoque");
}
void Getdatatable()
{
dt = db.Maisvendendo("select * from estoque");
}
private void MaisVendido_Load( object sender, EventArgs e )
{
reportViewer1.Visible = true;
reportViewer1.LocalReport.ReportPath = "Report3.rdlc";
ReportDataSource source = new ReportDataSource("Estoque", dt);
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(source);
reportViewer1.LocalReport.Refresh();
}
}
}
//in my db class i have dataset and datatable two fucnitons
public DataSet ClientTable( string query )
{
DataSet dt = new DataSet();
MySqlConnection con = new MySqlConnection(MysqlConnect());
con.Open();
MySqlCommand cmd = new MySqlCommand(query, con);
MySqlDataAdapter ad = new MySqlDataAdapter(query, con);
ad.Fill(dt);
return dt;
}
public DataTable Maisvendendo( String query )
{
DataTable dt = new DataTable();
MySqlConnection con = new MySqlConnection(MysqlConnect());
con.Open();
MySqlDataAdapter ad = new MySqlDataAdapter(query, con);
ad.Fill(dt);
dt.TableName = "Estoque";
con.Close();
return dt;
}
答案 0 :(得分:0)
您应该使用ReportPath代替ReportEmbeddedResource,因为您没有使用嵌入式资源,而是使用本地文件。