我是新来的报告。我正在使用MicrosoftaReportViewr来显示report.For我创建和填充数据集。然后我尝试将该数据集作为reportviewr1的源代码。但我没有得到实际coding.My代码如何通过C#编码在Windows窗体中显示报告?
if (cbReprt.Text == "FirmDetails")
{
ReportDocument rpt = new ReportDocument();
rpt.Load("C:\\Users\\ALEN\\Desktop\\Merchant\\MerchantAssociation\\MerchantAssociation\\CrystalReport1.rpt");
SqlConnection myCon;
SqlDataAdapter myAdapter;
DataSet1 myDataset = new DataSet1(); //The DataSet you created.
myCon = new SqlConnection("Data Source=202.88.231.102;Initial Catalog=dbs_Merchant;Persist Security Info=True;User ID=sa;Password=abc123*");
SqlCommand cmd3 = new SqlCommand("select * from View1", myCon);
cmd3.CommandType = CommandType.StoredProcedure;
myAdapter = new SqlDataAdapter(cmd3);
myAdapter.Fill(myDataset, "View1");
rpt.SetDataSource(myDataset);
reportViewer1.LocalReport.DataSources= rpt;
reportViewer1.RefreshReport();
}
但我reportViewer1.LocalReport.DataSources = RPT;显示错误... 需要或不需要任何特殊的命名空间?
你得到的错误是什么? – ryadavilli
您是否试图将CrystalReport加载到ReportViewer控件中?如果是这种情况,则必须安装适用于Visual Studio的SAP CrystalReports并使用其查看器,因为ReportViewer控件仅适用于SSRS报告格式(rdl/rdlc)。 – Vedran
运行时错误或编译错误?这是一个必要的开始。 – Rob