我查看了很多現有的問題,但我的問題仍然存在。Reportviewer綁定來自Mysql數據集?
我已經MaisVendido.Form
添加reportViewer1
,並且還增加了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;
}
通過從AddItem添加數據集和數據表,我成功地在reportwiever中顯示report.rdlc,但我想手動將數據集傳遞給report3.rdlc,並希望在Reportviewer中顯示,所以我無法做到這一點。 – Ahmed