既存の質問をたくさん見ましたが、私の問題はまだ残っています。
を追加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;
}