2017-04-26 127 views
1

レポートフォーム "Form1ReportSale"があります。私は別のフォームから来るIDに基づいてRDLCレポートを生成したいのです。プログラムをデバッグモードにすると、DataSetは期待値を返しますが、エラーをスローします。RDLC-ローカルレポート処理中にエラーが発生しました。レポート定義が無効です

Here is the error

マイ "Form1ReortSale" ロード・イベントコードは、次のされた添付ファイルをご覧ください:

public partial class Form1ReportSale : Form 
{ 
    string CS; 
    private string id; 
    public string UserID 
    { 
     get { return id; } 
     set { id = value; } 
    } 
    public Form1ReportSale() 
    { 
     InitializeComponent(); 
     CS = ConfigurationManager.ConnectionStrings["BikeDB"].ConnectionString; 
    } 

    private void Form1ReportSale_Load(object sender, EventArgs e) 
    { 
     this.WindowState = FormWindowState.Maximized; 
     //DataSet1NewCustomerBike dsCustomers = GetData(id); 
     reportViewer1.ProcessingMode = ProcessingMode.Local; 
     reportViewer1.LocalReport.ReportPath = @"E:\Working Area\Directorate Of IT Project\Own Practices\BikeShowRoom\BikeShowRoom\Reports\Form1ReportSale.cs"; 
     DataSet ds = new DataSet(); 
     ds = getDataByID(Convert.ToInt32(id)); 
     ReportDataSource datasource = new ReportDataSource("DataSet1Customer",ds.Tables[0]); 
     this.reportViewer1.LocalReport.DataSources.Clear(); 
     reportViewer1.LocalReport.DataSources.Add(datasource); 
     reportViewer1.LocalReport.Refresh(); 
     reportViewer1.RefreshReport(); 
    } 

    private DataSet getDataByID(int ID) 
    { 
     DataSet ds = new DataSet(); 
     using (SqlConnection con = new SqlConnection(CS)) 
     { 
      SqlCommand cmd = new SqlCommand("SELECT * FROM AddNewBike WHERE ID = '"+ID+"'", con); 
      SqlDataAdapter ad = new SqlDataAdapter(cmd); 
      con.Open(); 
      ad.Fill(ds); 
     } 
     return ds; 
    } 
} 

答えて

1

チェックアウトあなたが与えているパス:

reportViewer1.LocalReport.ReportPath = @"E:\Working Area\Directorate Of IT Project\Own Practices\BikeShowRoom\BikeShowRoom\Reports\Form1ReportSale.cs"; 

Form1ReportSaleレポート延長すべきです.cslの代わりに.rdlcにする...あなたのレポートに与えた正しい名前をコピーするか、これを試してください

reportViewer1.LocalReport.ReportPath = "~/Reports/Form1ReportSale.rdlc"; 
+0

私はパスを変更しました。ありがとうございますが、「ローカルレポート処理中にエラーが発生しました。」、「Microsoft.ReportingServices.ReportProcessing.ReportPrcoessingException: 'この指定された操作は無効です。助けてください。 –

+0

これを試してください。それがうまく動作しない場合は、私に教えてください.reportViewer1.LocalReport.ReportPath = "Form1ReportSale.rdlc"; –

+0

私のデータテーブルに問題がありました。私は 'select *'クエリを実行するが、私はdataTableにいくつかのフィールドを設定していない。どうもありがとうと私はあなたの質問をマークしています –

関連する問題