2013-03-12 99 views
21

レポートウィザードを使用してVS 2012で.rdlc-Reportを作成し、データソースとデータセットを追加しました。 私は、エラーメッセージ、次の取得の下のコードを使用してレポートをレンダリングしよう:.rdlcレポート - データセット 'DataSet1'のデータリーダーを作成できません

「データセットのデータリーダーを作成できません 『をDATASET1』。」任意の提案を事前に

bytes = localReport.Render("PDF", sdeviceinfo, out smimetype, out sencoding, out sfilenameextension, out streamids, out myWarnings); 

ありがとう!

答えて

1

1)管理者モードで実行していることと、SSRSサーバーにアクセスできることを確認してください。

2)正しいデータセット名を設定しているか、正しくロードして割り当てているかどうかを確認します。

MSDNのthisサンプルを確認してください。

幸運を祈る!

51

は私が

答えはReportDataSource(文字列のxxxは、DataTableのYYY)

あなたは右の名前を使うべきである「データセットの 『ZZZ』をデータリーダーを作成できません」という同じ問題を抱えています。 xxxはzzzでなければなりません

+2

お礼を、これは私のデバッグのかなり多くを救いました。 – Sharbel

+1

そして 'localReport.DataSources.Add()'に 'ReportDataSource'を忘れないでください - それが私の問題でした。 –

+0

は完璧に機能しました! –

3

ReportViewerを作成し、真のデータセットを提供することができません。パラメータ提供テクニックによりエラーが発生する可能性があります。 このように試してみてください。私はこの方法で解決しました。

protected void btnPdf_Click(object sender, EventArgs e) 
    { 
    ReportViewer viwer = new ReportViewer(); 
    ObjectDataSource ob = new ObjectDataSource("dataset.YourTableAdapter", "GetData"); 
    dataset.YourTableAdapter ds = new dataset.YourTableAdapter(); 

    string PDF = "PDF"; 
    string ReportType = "ReportType"; 
    Warning[] warnings = null; 
    string[] streamIds = null; 
    string mimeType = string.Empty; 
    string encoding = string.Empty; 
    string extension = string.Empty; 
    string filetype = string.Empty; 



    viwer.SizeToReportContent = true; 
    viwer.LocalReport.ReportPath = "reports/report/report.rdlc"; 
    viwer.ProcessingMode = ProcessingMode.Local; 
    ob.SelectParameters.Clear(); 
    ob.SelectParameters.Add(QueryStringEnum.CompanyID, CurrentCompanyID.ToString()); 

    ReportDataSource rds = new ReportDataSource("datasetname", (object) ds.GetData((long?)CurrentCompanyID.ToInt64()); 

    viwer.LocalReport.DataSources.Add(rds); 
    viwer.LocalReport.Refresh(); 

    byte[] bytes = viwer.LocalReport.Render("PDF", null, 
    out mimeType, out encoding, out extension, out streamIds, out warnings); 




} 
8

私の 'gotcha'は、DataSetがDatasetと同じではないという発見でした。

(私は他の誰がこの愚かな間違いを避けることができることを願ってはい、私は私が実際に公共のフォーラムでこれに認めていますことを実現)

1

私は問題を解決した - 私のコーディングエラーを - 私は省略していました以下のSQLServerDataSourceのためのASPXコードから「適切」なパラメータ値...

パラメータ名=「p_CSV_VEHICLES」

とのためのNOのDefaultValueはありません注意してください(それが判明した)という二つのパラメータ(= "p_CSV_VGROUPS"と= "p_CSV_VEHICLES")はデフォルト値として空文字列 ""を渡すことができませんでした。空文字列はselect coこれら2つのパラメータのntext

DefaultValueを追加し、DefaultValueを各パラメータの有効な文字列値に設定した後、レポートは自分のWebページのReportViewerコントロールに完全に表示されました。

ここに元の(動作していない)aspxコードです。

 <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:FCI_WebMainConnectionString %>" 
     SelectCommand="uspRPT_CostDetailFleet" SelectCommandType="StoredProcedure"> 
     <SelectParameters> 
      <asp:Parameter DefaultValue="5" Name="p_UID_DIVISION" Type="Int32" /> 
      <asp:Parameter DefaultValue="85" Name="p_UID_CUSTOMER" Type="Int32" /> 
      <asp:Parameter DefaultValue="FCIFLEETGRP" Name="p_SORT_ORDER" Type="String" /> 
      <asp:Parameter DefaultValue="" Name="p_CSV_VGROUPS" Type="String" /> 
      <asp:Parameter Name="p_CSV_VEHICLES" Type="String" /> 
      <asp:Parameter DbType="Date" DefaultValue="#01/01/2013#" Name="p_dtStart0" /> 
      <asp:Parameter DbType="Date" DefaultValue="#12/31/2013#" Name="p_dtEnd0" /> 
     </SelectParameters> 
    </asp:SqlDataSource> 
0

私も同じ問題がありました。RDLCレポートでは、RDLCレポートには、レコードまたは空のオブジェクト(空のオブジェクトにはメタデータが含まれる)のいずれかが必要なデータセットが必要です。

したがって、ベストプラクティスでは常に空のオブジェクトNullまたはnothingではありません)、またはその中にいくつかのレコードがあります。

0
reportviewer1.LocalReport.DataSources.Add(New ReportDataSource("DataSet1", ObjectDataSource1)) 

レポートにデータソースを設定するコードを投稿する方が良いでしょう。

エラーを表示
0

はDATASET1のデータ・セットのデータリーダーを作成することはできません。

private void frm_report_Load(object sender, EventArgs e) 
{ 

    this.reportViewer1.RefreshReport(); 
    reportViewer1.LocalReport.Refresh(); 
    reportViewer1.LocalReport.DataSources.Clear(); 
    reportViewer1.LocalReport.ReportEmbeddedResource = "cruds_reports.Report1.rdlc"; 

    SqlCommand cmd = new SqlCommand("select * from tbl_info",con); 
    SqlDataAdapter da = new SqlDataAdapter(); 
    DataSet ds = new DataSet(); 
    da.Fill(ds); 
    DataTable dt = new DataTable(); 
    dt = ds.Tables[0]; 
    if (dt.Rows.Count>0) 
    { 
     rds = new ReportDataSource("DataSet1", dt); 
     reportViewer1.LocalReport.DataSources.Add(rds); 
     rds.Value = dt; 
     reportViewer1.LocalReport.Refresh(); 
     reportViewer1.RefreshReport(); 
    } 
    else 
    { 
     return; 
    } 

} 
関連する問題