VS 2010 を使用しており、サンプル Web アプリケーションを作成しています。データセットとレポートを追加し、1 行だけを返す SP を作成しました。現在、変数は含まれていません。パラメータなしの単純な SP。Web アプリに aspx ページを追加し、そのページにレポート ビューアー コントロールを追加しました。私の Aspx ページは次のようになります。
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
Font-Size="8pt" InteractiveDeviceInfos="(Collection)"
WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
</rsweb:ReportViewer>
コードビハインドは次のようになります。
protected void Page_Load(object sender, EventArgs e)
{
ReportViewer1.Visible = true;
ReportDataSource dataSource = new ReportDataSource("DataSet1", LoadData().Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(dataSource);
ReportViewer1.LocalReport.Refresh();
}
private DataSet LoadData()
{
var dataset = new DataSet();
using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["CString"].ConnectionString))
{
var command = new SqlCommand("[spSampleReport]")
{
Connection = con,
CommandType = CommandType.StoredProcedure
};
var adap = new SqlDataAdapter(command);
con.Open();
adap.Fill(dataset, "DataSet1");
}
return dataset;
}
私の Web 構成では、httphandlers セクションに以下を追加しました。
実行中、ページには何も表示されません。レポート ビューアのツールバーも表示されません。