2012-09-26 65 views
0

我查看了很多現有的問題,但我的問題仍然存在。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; 
     } 
+0

通過從AddItem添加數據集和數據表,我成功地在reportwiever中顯示report.rdlc,但我想手動將數據集傳遞給report3.rdlc,並希望在Reportviewer中顯示,所以我無法做到這一點。 – Ahmed

回答

0

因爲你沒有使用嵌入的資源,你應該在的地方ReportEmbeddedResource的使用ReportPath,但本地文件。

+0

同樣沒有顯示? – Ahmed

+1

您是從報告切換到另一個報告還是設置報告?如果您正在切換,則需要先重置查看器。 – gustavodidomenico

+0

請嘗試查看此鏈接: http://www.codeproject.com/Articles/15597/Using-the-ASP-NET-2-0-ReportViewer-in-Local-Mode 如果仍然無法處理問題,讓我知道,我會幫助你。 – gustavodidomenico